简体   繁体   中英

Why does a "'DataFrame' object has no attribute 'date_time'" error come up for my first column?

I have a dataframe that starts with the date_time column and is followed by multiple variables like below.

在此处输入图片说明

However, when I try to graph time vs. variable, I get the "'DataFrame' object has no attribute 'date_time'" error.

fig, ax = plt.subplots(2, 1, figsize=(20,8))    
ax[0].plot(df.date_time, df.P1_VWC)
ax[1].plot(df.date_time, df.P2_VWC)

Any ideas why my first column is being ignored?

Thanks for your time, -Bojan

Your date_time is not a column rather than it is the index of the dataframe. To move back to as a column, you can reset the index of the dataframe by using this:

df = df.reset_index()

Otherwise, you can also use the index directly as MrFuppes suggested in the comment.

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