Python Forum

Full Version: Putting column name to dataframe, can't work.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I tried to put a column name for normal dataframe by putting df.columns = ['ColumnName'] It works. But, after I pd.concat(df,df1), I can't put a column name to it. Any idea

I also tried df.rename = ['ColumnName']
Do you want to change the name of an existing column (rename) or add a column? Adding a column is easy:
df['New Column Name'] = values
Where "New Column Name" is the name you want to use to ID the column and values is the list/array/whatever that you want to add.