In the previous blog post, we went over the two main panda’s data structures: Series and Dataframe. In this blog post, we are going to take things a step further and introduce you to Panda’s indexes and the operations you can perform on them.
First, let’s initial a series with a character-based index (which we used in the previous blog post)
In : s3 = Series([1,2,3,4],index=['a','b','c','d'])
One very useful feature is that indexes can be used the same way list index/numpy array indexes, except with non-integer values:
In : s3 Out: a 1 b 2 c 3 d 4 dtype: int64 In : s3[['a']] Out: a 1 dtype: int64 In : s3[['a','b']] Out: a 1 b 2 dtype: int64
They also support list/array like slicing, but again, on non-integer values:
In : s3['a':'b'] Out: a 1 b 2 dtype: int64