2024-03-29 13:37:42 发布
网友
我有一个python系列,我想选择它的最后5行。如果我使用ts[-5:-1],它不会返回最后一行。我该怎么做?谢谢!你知道吗
使用^{}:
s.tail(5)
或^{}:
s.iloc[-5:]
样品:
s = pd.Series(range(10)) print (s) 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 dtype: int32 print (s.tail(5)) 5 5 6 6 7 7 8 8 9 9 dtype: int32 print (s.iloc[-5:]) 5 5 6 6 7 7 8 8 9 9 dtype: int32
使用^{} :
或^{} :
样品:
相关问题 更多 >
编程相关推荐