Pandas-Beispiele#
Importe#
[1]:
import pandas as pd
import numpy as np
Scatter matrix#
Mit pandas.plotting.scatter_matrix lässt sich eine Streumatrix (Scatter-Matrix erstellen, z.B.:
[2]:
df = pd.DataFrame(np.random.randn(1000, 4), columns=['A','B','C','D'])
pd.plotting.scatter_matrix(df, alpha=0.2)
[2]:
array([[<AxesSubplot:xlabel='A', ylabel='A'>,
<AxesSubplot:xlabel='B', ylabel='A'>,
<AxesSubplot:xlabel='C', ylabel='A'>,
<AxesSubplot:xlabel='D', ylabel='A'>],
[<AxesSubplot:xlabel='A', ylabel='B'>,
<AxesSubplot:xlabel='B', ylabel='B'>,
<AxesSubplot:xlabel='C', ylabel='B'>,
<AxesSubplot:xlabel='D', ylabel='B'>],
[<AxesSubplot:xlabel='A', ylabel='C'>,
<AxesSubplot:xlabel='B', ylabel='C'>,
<AxesSubplot:xlabel='C', ylabel='C'>,
<AxesSubplot:xlabel='D', ylabel='C'>],
[<AxesSubplot:xlabel='A', ylabel='D'>,
<AxesSubplot:xlabel='B', ylabel='D'>,
<AxesSubplot:xlabel='C', ylabel='D'>,
<AxesSubplot:xlabel='D', ylabel='D'>]], dtype=object)

numpy.random.randn gibt eine Stichprobe (oder mehrere Stichproben) mit Standardnormalverteilung zurück. Die Parameter (d0, d1, …, dn)
sind optionale Ganzzahlen, die die Dimensionen des zurückgegebenen Arrays bestimmen.
Andrews plot#
In den letzten Jahren kamen weitere ausgefeilte statistische Visualisierungswerkzeuge hinzu, unter anderem Andrews plot für die Visualisierung mehrdimensionaler Daten:
[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]:
<AxesSubplot:>
