Skip to main content

hist

Draws a histogram of the DataFrame's columns.

A histogram is a representation of the distribution of data.

Syntax

hist(column=None, bins=10, **kwargs)

Parameters

Parameter

Type

Description

column

str or list of str, optional

Column name or list of names to use for creating the histogram. If None (default), all numeric columns are used.

bins

int, optional

Number of histogram bins to use. Default: 10.

**kwargs

optional

Additional keyword arguments.

Returns

plotly.graph_objs.Figure

Examples

Python
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()
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)