毒品相关的拦截在上升吗?

使用 pandas 分析警务活动

Kevin Markham

Founder, Data School

重采样价格

apple.groupby(apple.index.month).price.mean()
date_and_time
1    174.34
2    155.78
3    178.46
apple.price.resample('M').mean()
date_and_time
2018-01-31    174.34
2018-02-28    155.78
2018-03-31    178.46
使用 pandas 分析警务活动

重采样成交量

apple
date_and_time         price    volume          
2018-01-08 16:00:00  174.35  20567800
2018-01-09 16:00:00  174.33  21584000
2018-02-08 16:00:00  155.15  54390500
...                     ...       ...
apple.volume.resample('M').mean()
date_and_time
2018-01-31    21075900
2018-02-28    62531550
2018-03-31    27979650
Freq: M, Name: volume, Length: 3, dtype: float64
使用 pandas 分析警务活动

合并价格与成交量

monthly_price = apple.price.resample('M').mean()
monthly_volume = apple.volume.resample('M').mean()
pd.concat([monthly_price, monthly_volume], axis='columns')
date_and_time   price    volume
2018-01-31     174.34  21075900
2018-02-28     155.78  62531550
2018-03-31     178.46  27979650
monthly = pd.concat([monthly_price, monthly_volume],
                     axis='columns')
使用 pandas 分析警务活动

绘制价格与成交量(1)

monthly.plot()
plt.show()

苹果股票月均价格与成交量的单一折线图

使用 pandas 分析警务活动

绘制价格与成交量(2)

monthly.plot(subplots=True)
plt.show()

苹果股票月均价格与成交量的分开折线图

使用 pandas 分析警务活动

让我们练习!

使用 pandas 分析警务活动

Preparing Video For Download...