Skip to content

Commit 56fa1e9

Browse files
zhengruifengdongjoon-hyun
authored andcommitted
[MINOR][PYTHON][DOCS] Correct the examples of toPandas and toArrow
### What changes were proposed in this pull request? Correct the examples of `toPandas` and `toArrow` ### Why are the changes needed? they are not copy-pastable, and the example of `toArrow` is not correct ### Does this PR introduce _any_ user-facing change? doc-change ### How was this patch tested? manually check, the doc-tests are skipped due to pandas/pyarrow dependency ### Was this patch authored or co-authored using generative AI tooling? no Closes #52353 from zhengruifeng/fix_example_toxxx. Authored-by: Ruifeng Zheng <ruifengz@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
1 parent 86d310b commit 56fa1e9

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
@@ -6510,13 +6510,14 @@ def toArrow(self) -> "pa.Table":
65106510
65116511
Examples
65126512
--------
6513+
>>> df = spark.createDataFrame([(2, "Alice"), (5, "Bob")], schema=["age", "name"])
65136514
>>> df.toArrow() # doctest: +SKIP
65146515
pyarrow.Table
65156516
age: int64
65166517
name: string
65176518
----
6518-
age: [[2,5]]
6519-
name: [["Alice","Bob"]]
6519+
age: [[2],[5]]
6520+
name: [["Alice"],["Bob"]]
65206521
"""
65216522
...
65226523

@@ -6540,6 +6541,7 @@ def toPandas(self) -> "PandasDataFrameLike":
65406541
65416542
Examples
65426543
--------
6544+
>>> df = spark.createDataFrame([(2, "Alice"), (5, "Bob")], schema=["age", "name"])
65436545
>>> df.toPandas() # doctest: +SKIP
65446546
age name
65456547
0 2 Alice

0 commit comments

Comments
 (0)