2024-04-19 15:01:57 发布
网友
我有一个以日期为索引的每日价格数据框。如果索引日期为<;“2010/1/1”,我想删除所有行。我试过bars.drop(bars.index<'2010/7/17'== True)它引起了一个错误ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()。有什么想法吗?你知道吗
bars.drop(bars.index<'2010/7/17'== True)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
如果您真的想使用您的条件drop行,您可以执行以下操作:
drop
bars.drop(bars.index[bars.index<'2010/1/1'])
但最好使用@EdChum solution和loc对数据帧进行切片。你知道吗
loc
如果您真的想使用您的条件
drop
行,您可以执行以下操作:但最好使用@EdChum solution和
loc
对数据帧进行切片。你知道吗相关问题 更多 >
编程相关推荐