Examples
Estimate the PDF (probability density function) using KDE with automatic bandwidth
determination and plot from the results of a given Series of points randomly sampled
from an unknown distribution.
Evaluating them at 1000 equally spaced points(default):

In [1]:
import numpy as np
import pandas as pd
In [3]:
s = pd.Series([2, 3, 3.5, 4, 4.5, 5, 6])
ax = s.plot.kde()

A scalar bandwidth can be specified. Using a small bandwidth value can lead to over-fitting,
while using a large bandwidth value may result in under-fitting:

In [4]:
ax = s.plot.kde(bw_method=0.3)
In [5]:
ax = s.plot.kde(bw_method=3)

In the following example, the ind parameter determines the evaluation points for the plot of the estimated PDF:

In [6]:
ax = s.plot.kde(ind=[2, 3, 4, 5, 6])

For DataFrame, it works in the same way:

In [7]:
df = pd.DataFrame({
    'p': [2, 3, 3.5, 4, 4.5, 5, 6],
    'q': [5, 5, 5.5, 6, 6.5, 7, 7],
})
ax = df.plot.kde()

In the following example a scalar bandwidth can be specified. Using a
small bandwidth value can lead to over-fitting, while using a large bandwidth
value may result in under-fitting:

In [8]:
ax = df.plot.kde(bw_method=0.3)
In [9]:
ax = df.plot.kde(bw_method=3)

In the following example the ind parameter determines the evaluation points
for the plot of the estimated PDF:

In [10]:
ax = df.plot.kde(ind=[2, 3, 4, 5, 6, 7])