使用 DatetimeIndex 处理 pandas 系列。期望的结果是一个数据框,其中包含 .loc[] 函数中指定的范围内的所有行。
当我尝试以下代码时:
aapl.index = pd.to_datetime(aapl.index)
print(aapl.loc[pd.Timestamp('2010-11-01'):pd.Timestamp('2010-12-30')])
我回来了:
Empty DataFrame
Columns: [Open, High, Low, Close, Volume, ExDividend, SplitRatio,
AdjOpen, AdjHigh, AdjLow, AdjClose, AdjVolume]
Index: []
重申一下,我想要的结果是数据框的一个子集,包含范围内的所有行 (2010-11-01):(2010-12-30)。