I come up with a dataframe like this, I wonder how can we change or drop the 'id' and 'date' as they are just the names for index and columns.
id col1 col2 clo3
date
2000-01-03 55.500000 NaN NaN
2000-01-04 52.812500 NaN NaN
2000-01-05 52.750000 NaN NaN
2000-01-06 53.500000 NaN NaN
2000-01-07 53.625000 NaN NaN
2000-01-10 52.656250 NaN NaN
Option 1
rename_axis
df.rename_axis(None, 1, inplace=True) # 1 is for axis=1
Option 2
reassign df.columns
df.columns = df.columns.tolist()
Option 3
Setting the name
attribute, as described by Boud .
df.columns.name = None
df.index.name = None
These variables are represented through the name
property:
df.columns.name = None
df.index.name = None
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.