vDataFrame[].density

In [ ]:
vDataFrame[].density(by: str = "",
                     bandwidth: float = 1.0,
                     kernel: str = "gaussian",
                     nbins: int = 200,
                     xlim = None,
                     ax=None,
                     **style_kwds,)

Draws the density plot of the vcolumn.

Parameters

Name Type Optional Description
by
str
✓
vcolumn to use to partition the data.
bandwidth
float
✓
The bandwidth of the kernel.
kernel
str
✓
One of the following methods used for the plot:
  • gaussian : Gaussian Kernel.
  • logistic : Logistic Kernel.
  • sigmoid : Sigmoid Kernel.
  • silverman : Silverman Kernel.
nbins
int
✓
Maximum number of points to use to evaluate the approximate density function. Increasing this parameter will increase the precision but will also increase the time of the learning and scoring phases.
xlim
tuple
✓
Set the x limits of the current axes.
ax
Matplotlib axes object
✓
The axes to plot on.
**style_kwds
any
✓
Any optional parameter to pass to the Matplotlib functions.

Returns

ax : Matplotlib axes object

Example

In [1]:
from verticapy.datasets import load_iris
iris = load_iris()
display(iris)
123
SepalLengthCm
Numeric(5,2)
123
SepalWidthCm
Numeric(5,2)
123
PetalLengthCm
Numeric(5,2)
123
PetalWidthCm
Numeric(5,2)
Abc
Species
Varchar(30)
14.33.01.10.1Iris-setosa
24.42.91.40.2Iris-setosa
34.43.01.30.2Iris-setosa
44.43.21.30.2Iris-setosa
54.52.31.30.3Iris-setosa
64.63.11.50.2Iris-setosa
74.63.21.40.2Iris-setosa
84.63.41.40.3Iris-setosa
94.63.61.00.2Iris-setosa
104.73.21.30.2Iris-setosa
114.73.21.60.2Iris-setosa
124.83.01.40.1Iris-setosa
134.83.01.40.3Iris-setosa
144.83.11.60.2Iris-setosa
154.83.41.60.2Iris-setosa
164.83.41.90.2Iris-setosa
174.92.43.31.0Iris-versicolor
184.92.54.51.7Iris-virginica
194.93.01.40.2Iris-setosa
204.93.11.50.1Iris-setosa
214.93.11.50.1Iris-setosa
224.93.11.50.1Iris-setosa
235.02.03.51.0Iris-versicolor
245.02.33.31.0Iris-versicolor
255.03.01.60.2Iris-setosa
265.03.21.20.2Iris-setosa
275.03.31.40.2Iris-setosa
285.03.41.50.2Iris-setosa
295.03.41.60.4Iris-setosa
305.03.51.30.3Iris-setosa
315.03.51.60.6Iris-setosa
325.03.61.40.2Iris-setosa
335.12.53.01.1Iris-versicolor
345.13.31.70.5Iris-setosa
355.13.41.50.2Iris-setosa
365.13.51.40.2Iris-setosa
375.13.51.40.3Iris-setosa
385.13.71.50.4Iris-setosa
395.13.81.50.3Iris-setosa
405.13.81.60.2Iris-setosa
415.13.81.90.4Iris-setosa
425.22.73.91.4Iris-versicolor
435.23.41.40.2Iris-setosa
445.23.51.50.2Iris-setosa
455.24.11.50.1Iris-setosa
465.33.71.50.2Iris-setosa
475.43.04.51.5Iris-versicolor
485.43.41.50.4Iris-setosa
495.43.41.70.2Iris-setosa
505.43.71.50.2Iris-setosa
515.43.91.30.4Iris-setosa
525.43.91.70.4Iris-setosa
535.52.34.01.3Iris-versicolor
545.52.43.71.0Iris-versicolor
555.52.43.81.1Iris-versicolor
565.52.54.01.3Iris-versicolor
575.52.64.41.2Iris-versicolor
585.53.51.30.2Iris-setosa
595.54.21.40.2Iris-setosa
605.62.53.91.1Iris-versicolor
615.62.74.21.3Iris-versicolor
625.62.84.92.0Iris-virginica
635.62.93.61.3Iris-versicolor
645.63.04.11.3Iris-versicolor
655.63.04.51.5Iris-versicolor
665.72.55.02.0Iris-virginica
675.72.63.51.0Iris-versicolor
685.72.84.11.3Iris-versicolor
695.72.84.51.3Iris-versicolor
705.72.94.21.3Iris-versicolor
715.73.04.21.2Iris-versicolor
725.73.81.70.3Iris-setosa
735.74.41.50.4Iris-setosa
745.82.64.01.2Iris-versicolor
755.82.73.91.2Iris-versicolor
765.82.74.11.0Iris-versicolor
775.82.75.11.9Iris-virginica
785.82.75.11.9Iris-virginica
795.82.85.12.4Iris-virginica
805.84.01.20.2Iris-setosa
815.93.04.21.5Iris-versicolor
825.93.05.11.8Iris-virginica
835.93.24.81.8Iris-versicolor
846.02.24.01.0Iris-versicolor
856.02.25.01.5Iris-virginica
866.02.75.11.6Iris-versicolor
876.02.94.51.5Iris-versicolor
886.03.04.81.8Iris-virginica
896.03.44.51.6Iris-versicolor
906.12.65.61.4Iris-virginica
916.12.84.01.3Iris-versicolor
926.12.84.71.2Iris-versicolor
936.12.94.71.4Iris-versicolor
946.13.04.61.4Iris-versicolor
956.13.04.91.8Iris-virginica
966.22.24.51.5Iris-versicolor
976.22.84.81.8Iris-virginica
986.22.94.31.3Iris-versicolor
996.23.45.42.3Iris-virginica
1006.32.34.41.3Iris-versicolor
Rows: 1-100 | Columns: 5
In [4]:
iris["PetalLengthCm"].density()
Out[4]:
<AxesSubplot:ylabel='density'>
In [5]:
# Density using 10 points
iris["PetalLengthCm"].density(nbins=10)
Out[5]:
<AxesSubplot:ylabel='density'>
In [6]:
# Logistic Kernel
iris["PetalLengthCm"].density(kernel = "logistic")
Out[6]:
<AxesSubplot:ylabel='density'>
In [8]:
# Using a Partition
iris["PetalLengthCm"].density(by = "Species")
Out[8]:
<AxesSubplot:title={'center':'KernelDensity'}, xlabel='"PetalLengthCm"', ylabel='density'>
In [9]:
# Using a Partition and xlim
iris["PetalLengthCm"].density(by = "Species", xlim = [0, 10])
Out[9]:
<AxesSubplot:title={'center':'KernelDensity'}, xlabel='"PetalLengthCm"', ylabel='density'>

See Also

vDataFrame[].hist Draws the Histogram of the vcolumn based on an aggregation.