[英]Index pandas dataframe by date
我正在尝试使用以下方法按日期索引我的 Pandas 数据框:
df = pd.to_datetime(df)
但我收到以下错误:
ValueError: to assemble mappings requires at least that [year, month, day]
be specified: [day,month,year] is missing
我当前的熊猫数据框看起来像这样。
您正在尝试转换整个数据帧。 相反,您只想将该函数应用于数据帧索引。
df.index = pd.to_datetime(df.index)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.