In this section, we will focus on the final point: namely, how to slice, dice, and generally get and set subsets of pandas objects. The primary focus will be on Series and DataFrame as they have received more development attention in this area. read more
In [58]: s. sort_index Out[58]: 0 a 2 c 3 b 4 e 5 d dtype: object In [59]: s. sort_index (). loc [1: 6] Out[59]: 2 c 3 b 4 e 5 d dtype: object However, if at least one of the two is absent and the index is not sorted, an error will be raised (since doing otherwise would be computationally expensive, as well as potentially ambiguous for mixed type indexes). read more