具有日期时间索引的切片数据获取空数据帧

时间:2020-03-22 18:22:08

标签: pandas date

我有以下熊猫DataFrame:

df
Date
2020-03-16    747.86
2020-03-13    761.78
2020-03-12    769.25
2020-03-11    811.35
2020-03-10    837.50

2000-08-07    106.92
2000-08-04    105.20
2000-08-02    103.38
2000-07-31    101.55
2000-07-28    100.00
Name: Close, Length: 4738, dtype: float64

当我过滤df['2014-12']时,我得到了真实的数据片段:

Date
2014-12-31    545.63
2014-12-30    537.57
2014-12-29    532.68
2014-12-26    533.37
2014-12-25    532.01
2014-12-24    539.44
2014-12-23    537.88
2014-12-22    537.54
2014-12-19    523.09
2014-12-18    528.45
2014-12-17    518.22
2014-12-16    535.14
2014-12-15    547.93
2014-12-12    553.93
2014-12-11    550.11
2014-12-10    557.19
2014-12-09    555.31
2014-12-08    571.68
2014-12-05    578.76
2014-12-04    578.38
2014-12-03    574.88
2014-12-02    569.43
2014-12-01    568.01
Name: Close, dtype: float64

但是当我想从期间获取数据时,会导致以下情况:

df['2014-12-01':'2014-12-05']
Series([], Name: Close, dtype: float64)

df.loc['2014-12-01':'2014-12-05']
Series([], Name: Close, dtype: float64)

您能帮我从上述期间中提取数据吗?

谢谢

0 个答案:

没有答案