pandas examples¶
Imports¶
[1]:
import numpy as np
import pandas as pd
Scatter matrix¶
A `scatter matrix can be created with pandas.plotting.scatter_matrix , for example:
[2]:
df = pd.DataFrame(np.random.randn(1000, 4), columns=["A", "B", "C", "D"])
pd.plotting.scatter_matrix(df, alpha=0.2)
[2]:
array([[<Axes: xlabel='A', ylabel='A'>, <Axes: xlabel='B', ylabel='A'>,
<Axes: xlabel='C', ylabel='A'>, <Axes: xlabel='D', ylabel='A'>],
[<Axes: xlabel='A', ylabel='B'>, <Axes: xlabel='B', ylabel='B'>,
<Axes: xlabel='C', ylabel='B'>, <Axes: xlabel='D', ylabel='B'>],
[<Axes: xlabel='A', ylabel='C'>, <Axes: xlabel='B', ylabel='C'>,
<Axes: xlabel='C', ylabel='C'>, <Axes: xlabel='D', ylabel='C'>],
[<Axes: xlabel='A', ylabel='D'>, <Axes: xlabel='B', ylabel='D'>,
<Axes: xlabel='C', ylabel='D'>, <Axes: xlabel='D', ylabel='D'>]],
dtype=object)
numpy.random.randn returns a sample (or several samples) with a standard normal distribution. The parameters (d0, d1, …, dn)
are optional integers that determine the dimensions of the returned array.
Andrews plot¶
In recent years, further sophisticated statistical visualisation tools have been added, including Andrews plot for the visualisation of multidimensional data:
[3]:
df = pd.read_csv(
"https://raw.githubusercontent.com/pandas-dev/pandas/master/pandas/tests/io/data/csv/iris.csv"
)
pd.plotting.andrews_curves(df, "Name")
[3]:
<Axes: >