To rename a column in Pandas, you can use the rename
method. You can either rename a single column or multiple columns at once. Here's the syntax:
To rename a single column:
main.py115 chars5 lines
To rename multiple columns:
main.py155 chars5 lines
Note that the rename
method returns a new DataFrame, so you should assign the result back to the original variable to update it.
gistlibby LogSnag