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 ''.
Python – Rename unnamed column pandas dataframe
csvpandaspython
Best Answer
You can view the current dataframe using
data.head()
if that returns
'Unnamed: 0'
as the column title, you can rename it in the following way: