Pandas series name

2019-05-15 06:37发布

问题:

I am trying to name my series "Points" but it is not showing up as Points.

Points = pd.Series([1,2,3])

print(Points.name)
output: None

I even tried renaming it but it still shows "None"

Points.rename("Points")
print(Points.name)
output: None

What am i doing wrong?

回答1:

Points is your variable assigned the your series.

Points = Points.rename("Points")

Not "s" in the above example.

print(Points)

0    1
1    2
2    3
Name: Points, dtype: int64

and

print(Points.name)

'Points'