/Users/frhyme/anaconda3/lib/python3.6/site-packages/pandas_datareader/google/daily.py:40: UnstableAPIWarning:
The Google Finance API has not been stable since late 2017. Requests seem
to fail at random. Failure is especially common when bulk downloading.
warnings.warn(UNSTABLE_WARNING, UnstableAPIWarning)
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
idx = pd.date_range('2000-01-01', '2018-01-01')
df = pd.DataFrame({'x':np.cumsum(np.random.normal(0, 1, len(idx))*10)},
index = idx)
plt.figure(figsize=(15, 5))
plt.plot(df.index, df['x'])
plt.plot(df.resample('W').mean(), label='Week')
plt.plot(df.resample('M').mean(), label='Month')
plt.plot(df.rolling(180).mean(), label='180D')
plt.plot(df.resample('A').mean(), label='annual')
plt.legend()
plt.savefig("../../assets/images/markdown_img/180612_1422_df_time_series.svg")
plt.show()
x shift_-1 shift_1 shift_2
2000-01-01 -12.235593 -11.298887 NaN NaN
2000-01-02 -11.298887 15.379539 -12.235593 NaN
2000-01-03 15.379539 19.195769 -11.298887 -12.235593
2000-01-04 19.195769 16.808412 15.379539 -11.298887
2000-01-05 16.808412 17.593410 19.195769 15.379539
2000-01-06 17.593410 17.818314 16.808412 19.195769
2000-01-07 17.818314 22.679743 17.593410 16.808412
2000-01-08 22.679743 29.726933 17.818314 17.593410
2000-01-09 29.726933 34.502865 22.679743 17.818314
2000-01-10 34.502865 6.953065 29.726933 22.679743
댓글남기기