How can I change the name of a Series
object?
rename() function is used to alter Series index labels or name for the given Series object. inplace : Whether to return a new Series. If True then value of copy is ignored.
You can use the rename() method of pandas. DataFrame to change column/index name individually. Specify the original name and the new name in dict like {original name: new name} to columns / index parameter of rename() .
The name of a Series becomes its index or column name if it is used to form a DataFrame. It is also used whenever displaying the Series using the interpreter.
Not sure why no one mentioned rename
s.rename("new_name", inplace=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With