Reputation: 19395
We are all familiar with the classic question of rotating a list to the left, say:
mylist = [1,2,3,4,5,6,7]
#rotate by two to the left
mylist[2:] + mylist[:2]
Out[4]: [3, 4, 5, 6, 7, 1, 2]
Now consider the same list, as a Pandas
series.
pdlist = pd.Series(mylist)
Out[8]:
0 1
1 2
2 3
3 4
4 5
5 6
6 7
dtype: int64
How can I rotate it in the same way, by only using Pandas functions?
Thanks!
Upvotes: 1
Views: 53