【发布时间】:2016-06-15 17:51:02
【问题描述】:
我已经从雅虎财经下载了每日数据
Open High Low Close Volume \
Date
2016-01-04 10485.809570 10485.910156 10248.580078 10283.440430 116249000
2016-01-05 10373.269531 10384.259766 10173.519531 10310.099609 82348000
2016-01-06 10288.679688 10288.679688 10094.179688 10214.019531 87751700
2016-01-07 10144.169922 10145.469727 9810.469727 9979.849609 124188100
2016-01-08 10010.469727 10122.459961 9849.339844 9849.339844 95672200
...
2016-02-23 9503.120117 9535.120117 9405.219727 9416.769531 87240700
2016-02-24 9396.480469 9415.330078 9125.190430 9167.799805 99216000
2016-02-25 9277.019531 9391.309570 9199.089844 9331.480469 0
2016-02-26 9454.519531 9576.879883 9436.330078 9513.299805 95662100
2016-02-29 9424.929688 9498.570312 9332.419922 9495.400391 90978700
我想找出每个月的最高收盘价以及这个收盘价的日期。
使用 groupby dfM = df['Close'].groupby(df.index.month).max() 它会返回每月的最大值,但我会失去每日索引位置。
grouped by month
1 10310.099609
2 9757.879883
有没有保存索引的好方法?
我会寻找这样的结果:
grouped by month
2016-01-05 10310.099609
2016-02-01 9757.879883
【问题讨论】:
标签: python pandas group-by max time-series