series = pd.Series(['A', 'B', 'C','D'], index=['a', 'b', 'c', 'd'])
I want:
c C
b B
a A
dtype: object
I tried:
series['a':'c':-1]
but I'm getting:
Series([], dtype: object)
CodePudding user response:
series['c':'a':-1]
output:
c C
b B
a A
dtype: object
CodePudding user response:
You can also use series.loc
to obtain the same result.
series.loc['c'::-1]
c C
b B
a A
dtype: object