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
- A Column With a Name and Index
- Label-Based vs Position-Based Access
- Series Math and Alignment
- Counting and Spotting Values