我试图给我的系列命名为“点”,但它并没有显示为“Points”。
Points = pd.Series([1,2,3])
print(Points.name)
output: None
我甚至尝试重命名,但仍然显示“None”。
Points.rename("Points")
print(Points.name)
output: None
我做错了什么?
Points = Points.rename("Points")
print(Points)
0 1
1 2
2 3
Name: Points, dtype: int64
并且
print(Points.name)
'Points'
Points.rename('Points')
返回 Points
的一个副本。你需要像他展示的那样重新分配给名称 Points
。 - piRSquared
pd
或Series
的变量?这些可能是罪魁祸首。尝试退出解释器并重新执行。 - Brad Solomon