Skip to content

Commit 1ec647e

Browse files
committed
[SPARK-53630][PYTHON][DOCS][TESTS] Reenable doctest for Dataframe.freqItems
### What changes were proposed in this pull request? Reenable doctest for `Dataframe.freqItems`, by make the example deterministic ### Why are the changes needed? for test coverage and make sure the example is fine ### Does this PR introduce _any_ user-facing change? doc-only ### How was this patch tested? ci ### Was this patch authored or co-authored using generative AI tooling? no Closes #52380 from zhengruifeng/freq_item_sort. Authored-by: Ruifeng Zheng <[email protected]> Signed-off-by: Ruifeng Zheng <[email protected]>
1 parent b87f6d1 commit 1ec647e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

python/pyspark/sql/dataframe.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5522,12 +5522,14 @@ def freqItems(
55225522
55235523
Examples
55245524
--------
5525+
>>> from pyspark.sql import functions as sf
55255526
>>> df = spark.createDataFrame([(1, 11), (1, 11), (3, 10), (4, 8), (4, 8)], ["c1", "c2"])
5526-
>>> df.freqItems(["c1", "c2"]).show() # doctest: +SKIP
5527+
>>> df = df.freqItems(["c1", "c2"])
5528+
>>> df.select([sf.sort_array(c).alias(c) for c in df.columns]).show()
55275529
+------------+------------+
55285530
|c1_freqItems|c2_freqItems|
55295531
+------------+------------+
5530-
| [4, 1, 3]| [8, 11, 10]|
5532+
| [1, 3, 4]| [8, 10, 11]|
55315533
+------------+------------+
55325534
"""
55335535
...

0 commit comments

Comments
 (0)