简体   繁体   中英

Index pandas dataframe by date

I am trying to index my pandas dataframe by date by using:

df = pd.to_datetime(df)

but am getting the following error:

    ValueError: to assemble mappings requires at least that [year, month, day] 

    be specified: [day,month,year] is missing

My current pandas dataframe looks like this.

You're trying to convert the entire dataframe. Instead, you just want to apply the function to the dataframe index.

df.index = pd.to_datetime(df.index)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM