Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame({
    'AU': [6.0505, 6.0963, 6.3549],
    'IT': [5.7446, 5.7482, 5.8919],
    'DK': [904.76, 910.02, 960.14]},
    index=['1999-01-01', '1999-02-01', '1999-03-01'])
df
Out[2]:
AU IT DK
1999-01-01 6.0505 5.7446 904.76
1999-02-01 6.0963 5.7482 910.02
1999-03-01 6.3549 5.8919 960.14
In [3]:
df.pct_change()
Out[3]:
AU IT DK
1999-01-01 NaN NaN NaN
1999-02-01 0.007570 0.000627 0.005814
1999-03-01 0.042419 0.024999 0.055076

Percentage of change in GOOG and APPL stock volume. Shows computing the percentage
change between columns:

In [4]:
df = pd.DataFrame({
     '2006': [1869950, 32586265],
     '2005': [1600923, 44912316],
     '2004': [1271819, 45403351]},
     index=['GOOG', 'APPL'])
df
Out[4]:
2006 2005 2004
GOOG 1869950 1600923 1271819
APPL 32586265 44912316 45403351
In [5]:
df.pct_change(axis='columns')
Out[5]:
2006 2005 2004
GOOG NaN -0.143869 -0.205571
APPL NaN 0.378259 0.010933