Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas: renaming Series.name

Tags:

python

pandas

Given:

import pandas as pd

s = pd.Series(name="myname")

When:
I want to rename it to newname2

Then:
why should I use s.rename("newname2") instead of s.name = "newname2" ?

like image 930
stakowerflol Avatar asked Nov 20 '25 02:11

stakowerflol


1 Answers

Both approaches are fine. the rename function has more functionality than just changing the name attribute of your pd.Series object, you could actually change the label of your indexes.

see more @ pandas documentation

like image 181
Steven G Avatar answered Nov 21 '25 16:11

Steven G



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!