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" ?
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
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