To change the column name in pandas dataframe, you can use the rename()
method. Here's an example:
main.py367 chars17 lines
In the example above, the rename()
method is used to change the column name 'A' to 'NewColumn'. You can also specify multiple column name changes by providing a dictionary with the old column names as keys and the new column names as values.
Remember to assign the modified dataframe back to the same variable if you want to keep the changes.
gistlibby LogSnag