0PricingLogin
Data Science Academy · Lesson

Label-Based vs Position-Based Access

Choosing loc or iloc with confidence.

Two Ways to Reach In

A Series has both labels and positions, so there are two ways to grab a value: by its label or by its position number. Knowing which to use keeps your code clear. 🎯

Our Sample Series

Here is a small Series with string labels. We will use it to compare both access styles throughout this lesson.

import pandas as pd
s = pd.Series([90, 75, 88], index=['Ada', 'Bo', 'Cy'])

All lessons in this course

  1. A Column With a Name and Index
  2. Label-Based vs Position-Based Access
  3. Series Math and Alignment
  4. Counting and Spotting Values
← Back to Data Science Academy