In Numpy arrays, we are familiar with the concepts of indexing, slicing, and masking, etc. Similarly, Pandas to supports indexing in their Dataframe. If we are familiar with the indexing in Numpy arrays, the indexing in Pandas will be very easy.

What is Indexing in Python?

Selecting values from particular rows and columns in a dataframe is known as Indexing. By using Indexing, we can select all rows and some columns or some rows and all columns.

Let’s create a sample data in a series form for better understanding of indexing.

The output series looks like this,

1    a
3    b
5    c
dtype: object

Now, here Python offers two types of indices

  • Explicit
  • Implicit

Explicit Indexing:

For the above dataset if we pass the command as,

ds[1] it uses explicit indices

## If we pass the above command ds[1], the output will be

'a'

This is Explicit Indexing. Whereas, if we pass the command ds[1:3] it will use the implicit index style,

#python #pandas #indexing #iloc #loc

Indexing in Pandas Dataframe using Python
1.10 GEEK