<jupyter_start><jupyter_text>Getting Transforming and Exploring Data<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import pandas_datareader as pdr
gld = pdr.get_data_yahoo('GLD', start='2013-01-01')
gld = gld.drop('Adj Close', axis=1)
gld =round(gld,2)
gld.head()
with plt.style.context('ggplot'):
    plt.plot(gld.Close)
gld.index = pd.DatetimeIndex(gld.index)
monthly = gld.resample('BM').last()
monthly.head()
plt.plot(monthly['Close'])
gld['Change'] = gld['Close'] -gld['Close'].shift()
gld.head()
gld['LN_change'] = np.log(gld['Close']/ gld['Close'].shift())
gld.head()
with plt.style.context('ggplot'):
    plt.figure(figsize=(10,8))
    plt.hist(gld.LN_change[1:],bins=50,edgecolor='black', density='True')
gld['Daily Vol'] = gld['LN_change'].rolling(21).std().shift()
gld['Exp Change'] = gld['Close'] * gld['Daily Vol']
gld.head(23)
gld = gld[22:]
gld.head()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup