pyspark.sql.DataFrame.plot#
- property DataFrame.plot#
Returns a
plot.core.PySparkPlotAccessor
for plotting functions.New in version 4.0.0.
- Returns
plot.core.PySparkPlotAccessor
Notes
This API is experimental. It provides two ways to create plots: 1. Chaining style (e.g., df.plot.line(…)). 2. Explicit style (e.g., df.plot(kind=”line”, …)).
Examples
>>> data = [("A", 10, 1.5), ("B", 30, 2.5), ("C", 20, 3.5)] >>> columns = ["category", "int_val", "float_val"] >>> df = spark.createDataFrame(data, columns) >>> type(df.plot) <class 'pyspark.sql.plot.core.PySparkPlotAccessor'> >>> df.plot.line(x="category", y=["int_val", "float_val"]) >>> df.plot(kind="line", x="category", y=["int_val", "float_val"])