Pandas is a popular Python-based data analysis toolkit that can be imported using:
" import pandas as pd.
"
It presents a diverse range of utilities from parsing multiple file-formats to converting an entire data table into a NumPy matrix array. This property makes pandas a trusted ally in data science and machine learning.
Pandas can help with the creation of multiple types of data analysis graphs. One such example is the
A hexagonal plot is especially useful if the scatter plot is too dense to interpret. It helps to bin the area of the chart and assigns color intensity accordingly (where darker colors are deployed at areas with concentrated points).
The default implementation of a hexagonal bin plot is:
DataFrame.plot.hexbin(x, y, C=None, reduce_C_function = None **kwargs)
x
: int or string - The columns label or position for x points.
y
: int or string - The columns label or position for y points.
C
: int or string - The columns label or position for (x, y) values.
reduce_C_function
: callable - Function of an argument that reduces all the values in a bin to a single number by the use of np.mean, np.max, np.sum, or np.std. The default is np.mean.
gridsize
: int or (int, int) - The number of hexagons in the x-direction. They can also be the number of x and y hexagons.
**kwargs
: tuple (rows, columns) - All other plotting keyword arguments to be passed to matplotlib.pyplot.boxplot().
The following code shows how hexagon bins can be added in Python. You can change the different parameters to see how the output varies.
import pandas as pd import numpy as np #draw dataframe df = pd.DataFrame({'x_axis': np.random.rand(10000), 'y_axis': np.random.rand(10000)}) #plot the hexagonalbin plot plot = df.plot.hexbin(x = 'x_axis', y = 'y_axis', gridsize = 15)
RELATED TAGS
View all Courses