Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Accessor für DataFrame-Darstellungsfunktionen in PySpark.
Syntax
# Call the accessor directly
df.plot(kind="line", ...)
# Use a dedicated method
df.plot.line(...)
Methodik
| Methode | Beschreibung |
|---|---|
area(x, y, **kwargs) |
Zeichnet ein gestapeltes Flächenplot. |
bar(x, y, **kwargs) |
Zeichnet ein vertikales Balkenplot. |
barh(x, y, **kwargs) |
Zeichnet ein horizontales Balkenplot. |
box(column, **kwargs) |
Zeichnet ein Box-and-Whisker-Plot aus DataFrame-Spalten. |
hist(column, bins, **kwargs) |
Zeichnet ein Histogramm der DataFrame-Spalten. |
kde(bw_method, column, ind, **kwargs) |
Generiert ein Kerneldichteschätzungsplot mit gaussischen Kerneln. |
line(x, y, **kwargs) |
Zeichnet DataFrame-Spalten als Linien. |
pie(x, y, **kwargs) |
Generiert ein Kreisplot. |
scatter(x, y, **kwargs) |
Erstellt ein Punktdiagramm. |
Beispiele
Linienplot
data = [("A", 10, 1.5), ("B", 30, 2.5), ("C", 20, 3.5)]
columns = ["category", "int_val", "float_val"]
df = spark.createDataFrame(data, columns)
df.plot.line(x="category", y="int_val")
Balkenplot
data = [("A", 10, 1.5), ("B", 30, 2.5), ("C", 20, 3.5)]
columns = ["category", "int_val", "float_val"]
df = spark.createDataFrame(data, columns)
df.plot.bar(x="category", y="int_val")
Streudiagramm
data = [(5.1, 3.5, 0), (4.9, 3.0, 0), (7.0, 3.2, 1), (6.4, 3.2, 1), (5.9, 3.0, 2)]
columns = ["length", "width", "species"]
df = spark.createDataFrame(data, columns)
df.plot.scatter(x="length", y="width")
Flächenplot
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.area(x="date", y=["sales", "signups", "visits"])
Boxplot
data = [
("A", 50, 55), ("B", 55, 60), ("C", 60, 65),
("D", 65, 70), ("E", 70, 75), ("F", 10, 15),
]
columns = ["student", "math_score", "english_score"]
df = spark.createDataFrame(data, columns)
df.plot.box()
KDE-Zeichnung
data = [(5.1, 3.5, 0), (4.9, 3.0, 0), (7.0, 3.2, 1), (6.4, 3.2, 1), (5.9, 3.0, 2)]
columns = ["length", "width", "species"]
df = spark.createDataFrame(data, columns)
df.plot.kde(bw_method=0.3, ind=100)
Histogramm
data = [(5.1, 3.5, 0), (4.9, 3.0, 0), (7.0, 3.2, 1), (6.4, 3.2, 1), (5.9, 3.0, 2)]
columns = ["length", "width", "species"]
df = spark.createDataFrame(data, columns)
df.plot.hist(bins=4)