pyspark.sql.plot.core.PySparkPlotAccessor.pie#

PySparkPlotAccessor.pie(x, y, **kwargs)[source]#

Generate a pie plot.

A pie plot is a proportional representation of the numerical data in a column.

Parameters
xstr

Name of column to be used as the category labels for the pie plot.

ystr, optional

Name of the column to plot. If not provided, subplots=True must be passed at kwargs.

**kwargs

Additional keyword arguments.

Returns
plotly.graph_objs.Figure

Examples

>>> from datetime import datetime
>>> data = [
...     (3, 5, 20, datetime(2018, 1, 31)),
...     (2, 5, 42, datetime(2018, 2, 28)),
...     (3, 6, 28, datetime(2018, 3, 31)),
...     (9, 12, 62, datetime(2018, 4, 30))
... ]
>>> columns = ["sales", "signups", "visits", "date"]
>>> df = spark.createDataFrame(data, columns)
>>> df.plot.pie(x='date', y='sales')  
>>> df.plot.pie(x='date', subplots=True)