My csv file has no column name for the first column, and I want to rename it. Usually, I would do data.rename(columns={'oldname':'newname'}, inplace=True), but there is no name in the csv file, just ''.
data.rename(columns={'oldname':'newname'}, inplace=True)
You can view the current dataframe using data.head()
data.head()
if that returns 'Unnamed: 0' as the column title, you can rename it in the following way:
'Unnamed: 0'
data.rename( columns={'Unnamed: 0':'new column name'}, inplace=True )
2.1m questions
2.1m answers
60 comments
56.9k users