Indexing in Pandas

In this lesson, we will learn how Indexing works in Pandas. We can easily index and select data in Pandas.

Let’s say we have the following CSV file Students.csv:

CSV in Pandas

Indexing

Indexing means selecting specific rows and columns of data from DataFrame. A DataFrame includes columns, index, and data. Let us see some examples:

  • Indexing in Pandas using the indexing operator
  • Indexing in Pandas using loc[]
  • Indexing in Pandas using iloc[]

Indexing in Pandas using the indexing operator

We can directly use the [] i.e. the indexing operator in Pandas to retrieve records. Let us see an example:

Output

Indexing in Pandas using loc[]

To retrieve a single row in Pandas, use the loc[] in Pandas. Let us see an example:

Output

Indexing in Pandas using iloc[]

To retrieve the rows and columns by position, use the iloc[] in Pandas. Let us see an example:

Output

If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.


For Videos, Join Our YouTube Channel: Join Now


Read More:

Sorting in Pandas
Pandas - Cleaning the Data
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading