Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Generates a pie plot.
A pie plot is a proportional representation of the numerical data in a column.
Syntax
pie(x, y=None, **kwargs)
Parameters
| Parameter | Type | Description |
|---|---|---|
x |
str | Name of column to use as the category labels for the pie plot. |
y |
str, optional | Name of the column to plot. If not provided, subplots=True must be passed in kwargs. |
subplots |
bool, optional | If True, creates a separate subplot for each numeric column in the DataFrame. Default: False. Passed via kwargs. |
**kwargs |
optional | Additional keyword arguments. |
Returns
plotly.graph_objs.Figure
Examples
from pyspark.sql import SparkSession
from datetime import datetime
spark = SparkSession.builder.getOrCreate()
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')