Tsallaka zuwa abun ciki
Justice Tech School

Series with a Custom Index

A Series can have labels instead of numbers. Use them with [] or .loc.

Example
s = pd.Series([92, 78, 85], index=["Ada", "Kofi", "Amina"])
print(s["Ada"], s.loc["Kofi"], s.iloc[2])
print(s[["Ada", "Amina"]])

Result

92 78 85
Ada      92
Amina    85
dtype: int64

Exercise

Label access.

s.["Ada"]

Quiz Test

What does iloc use?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.