简体   繁体   中英

How to convert Index column with name 'Date' to weekday name in dataframe. The index format is dtype: int64

How to convert Index column with name Data to weekday name in dataframe

try:

daynumber = [0,1,2,3,4,5,6]
weekday = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
df = df.rename(index=dict(zip(daynumber,weekday)))
df

output:

Date       ...
Monday     ...
Tuesday    ...
Wednesday  ...
Thursday   ...
Friday     ...

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