Indexing in pandas. Not getting expected output

Viewed 38
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)
2 Answers
series['c':'a':-1]

output:

c    C
b    B
a    A
dtype: object

You can also use series.loc to obtain the same result.

series.loc['c'::-1]

c    C
b    B
a    A
dtype: object
Related