O'Reilly logo

Mastering pandas by Femi Anthony

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Label, integer, and mixed indexing

In addition to the standard indexing operator [] and attribute operator, there are operators provided in pandas to make the job of indexing easier and more convenient. By label indexing, we generally mean indexing by a header name, which tends to be a string value in most cases. These operators are as follows:

  • The .loc operator: It allows label-oriented indexing
  • The .iloc operator: It allows integer-based indexing
  • The .ix operator: It allows mixed label and integer-based indexing

We will now turn our attention to these operators.

Label-oriented indexing

The .loc operator supports pure label-based indexing. It accepts the following as valid inputs:

  • A single label such as ['March'], [88] or ['Dubai']. Note that in the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required