[英]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.