In [46]:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from IPython.display import display_html
%matplotlib inline
ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
ts.plot()
Out[46]:
In [27]:
df = pd.DataFrame(ts, columns=['A'])
df['B'] = df['A'] ** 2
df['C'] = np.exp(df['B'])
df.cumsum().plot(x='A', y='B', figsize=(6, 4))
Out[27]:
In [29]:
df.cumsum().hist(figsize=(20, 8))
Out[29]:
In [44]:
df = pd.DataFrame({
'B': np.random.randint(0, 100, 5),
'C': np.random.randint(50, 150, 5),
'D': np.random.randint(0, 100, 5),
}, index=list('ABCDE'))
# plt.figure()
df['B'].plot(kind='bar')
df.plot(kind='bar')
df.plot(kind='bar', stacked=True)
df.plot(kind='barh', stacked=True)
Out[44]:
In [45]:
df.plot(kind='hist')
Out[45]:
In [47]:
df = pd.DataFrame(np.random.rand(10, 5), columns=list('ABCDE'))
display_html(df)
df.plot(kind='box')
Out[47]:
In [57]:
df = pd.DataFrame(np.random.rand(10,3), columns=['Col1', 'Col2', 'Col3'] )
df['X'] = pd.Series(['A','A','A','A','A','B','B','B','B','B'])
df['Y'] = pd.Series(['A','B','A','B','A','B','A','B','A','B'])
display_html(df)
df.boxplot(column=['Col1', 'Col2'], by=['X', 'Y'], figsize=(20, 5))
Out[57]:
In [72]:
df = pd.DataFrame(np.random.rand(50, 4), columns=['a', 'b', 'c', 'd'])
ax = df.plot(kind='scatter', x='a', y='d', figsize=(8, 8), label='group 1', color='green')
df.plot(kind='scatter', x='b', y='c', figsize=(8, 8), ax=ax, label='group 2', color='red')
df.plot(kind='scatter', x='a', y='b', c='c', figsize=(11, 8), color='purple')
df.plot(kind='scatter', x='a', y='b', s=df['c'] * 200, figsize=(8, 8))
Out[72]:
In [85]:
df = pd.DataFrame(np.random.randn(1000, 2), columns=['a', 'b'])
df['b'] = df['b'] + np.arange(1000)
df.plot(kind='hexbin', x='a', y='b', gridsize=10)
df.plot(kind='hexbin', x='a', y='b', gridsize=50)
Out[85]:
In [93]:
df = pd.DataFrame(np.random.randn(1000, 2), columns=['a', 'b'])
df['b'] = df['b'] + np.arange(1000)
df['z'] = np.random.uniform(0, 3, 1000)
df.plot(kind='hexbin', x='a', y='b', C='z', reduce_C_function=np.mean, gridsize=25, figsize=(10, 5))
df.plot(kind='hexbin', x='a', y='b', C='z', reduce_C_function=np.max, gridsize=25, figsize=(10, 5))
Out[93]:
In [108]:
df = pd.DataFrame(np.random.rand(5, 2), columns=['X', 'Y'])
# display_html(df)
df.plot(kind='pie', subplots=True, figsize=(12, 6), labels=list('ABCDE'), autopct='%.1f%%', fontsize=16, table=True)
Out[108]:
In [ ]: