Python pandas has a pct_change function which I use to calculate the returns for stock prices in a dataframe:
ndf[\'Return\']= ndf[\'TypicalPrice\'].pct_chan
Log returns are simply the natural log of 1 plus the arithmetic return. So how about this?
df['pct_change'] = df.price.pct_change() df['log_return'] = np.log(1 + df.pct_change)