import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
# 新建一个时间序列
t_range = pd.date_range('2016-01-01', '2016-12-31', freq='H')
t_range# DatetimeIndex(['2016-01-01 00:00:00', '2016-01-01 01:00:00',
# '2016-01-01 02:00:00', '2016-01-01 03:00:00',
# '2016-01-01 04:00:00', '2016-01-01 05:00:00',
# '2016-01-01 06:00:00', '2016-01-01 07:00:00',
# '2016-01-01 08:00:00', '2016-01-01 09:00:00',
# ...
# '2016-12-30 15:00:00', '2016-12-30 16:00:00',
# '2016-12-30 17:00:00', '2016-12-30 18:00:00',
# '2016-12-30 19:00:00', '2016-12-30 20:00:00',
# '2016-12-30 21:00:00', '2016-12-30 22:00:00',
# '2016-12-30 23:00:00', '2016-12-31 00:00:00'],
# dtype='datetime64[ns]', length=8761, freq='H')
# 建立一个DataFrame
stock_df = pd.DataFrame(index=t_range)
# 加入两行,模拟股票
stock_df['BABA'] = np.random.randint(80, 100, size=len(t_range))
stock_df['TENCENT'] = np.random.randint(30, 50, size=len(t_range))# 显示图片,下面
stock_df.plot()