这是我的数据框(时间是索引):
price
time
2015-11-07 00:00:00 180.250000
2015-11-07 00:15:00 176.350000
2015-11-07 00:30:00 177.533333
2015-11-08 00:45:00 180.216667
我想删除当天'2015-11-07'的所有条目,所以我尝试了:
remove = df.loc['2015-11-07]
df.drop(remove)
但我收到此错误labels ['price'] not contained in axis
答案 0 :(得分:2)
您需要index
名为DataFrame
的{{1}}移除
remove
另一种解决方案:
remove = df.loc['2015-11-07']
print (remove)
price
time
2015-11-07 00:00:00 180.250000
2015-11-07 00:15:00 176.350000
2015-11-07 00:30:00 177.533333
print (df.drop(remove.index))
price
time
2015-11-08 00:45:00 180.216667