Skip to content

Commit

Permalink
[SPARK-49948][PS][CONNECT] Add parameter "precision" to pandas on Spa…
Browse files Browse the repository at this point in the history
…rk box plot

### What changes were proposed in this pull request?
Add parameter "precision" to pandas on Spark box plot.

### Why are the changes needed?
Previously, the box method used **kwds, allowing precision to be passed implicitly. Now, adding precision directly to the signature ensures clarity and explicit control, improving usability.

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Existing tests.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #48445 from xinrong-meng/ps_box.

Authored-by: Xinrong Meng <[email protected]>
Signed-off-by: Xinrong Meng <[email protected]>
  • Loading branch information
xinrong-meng committed Oct 16, 2024
1 parent 0e75d19 commit 861b5e9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions python/pyspark/pandas/plot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ def barh(self, x=None, y=None, **kwargs):
elif isinstance(self.data, DataFrame):
return self(kind="barh", x=x, y=y, **kwargs)

def box(self, **kwds):
def box(self, precision=0.01, **kwds):
"""
Make a box plot of the DataFrame columns.
Expand All @@ -857,14 +857,13 @@ def box(self, **kwds):
Parameters
----------
**kwds : optional
Additional keyword arguments are documented in
:meth:`pyspark.pandas.Series.plot`.
precision: scalar, default = 0.01
This argument is used by pandas-on-Spark to compute approximate statistics
for building a boxplot. Use *smaller* values to get more precise
statistics (matplotlib-only).
statistics.
**kwds : optional
Additional keyword arguments are documented in
:meth:`pyspark.pandas.Series.plot`.
Returns
-------
Expand Down Expand Up @@ -902,7 +901,7 @@ def box(self, **kwds):
from pyspark.pandas import DataFrame, Series

if isinstance(self.data, (Series, DataFrame)):
return self(kind="box", **kwds)
return self(kind="box", precision=precision, **kwds)

def hist(self, bins=10, **kwds):
"""
Expand Down

0 comments on commit 861b5e9

Please sign in to comment.