- Create from a list:
pd.Series([10, 20, 30]) - Custom labels:
pd.Series([...], index=["a", "b", "c"]) - From a dict: keys become labels.
- Access by label
s["a"]or positions.iloc[0].
Pandas Series
One-dimensional labelled data.
✍️ 3 exercises + code challenge in this lessonKey Takeaways: Pandas Series
Mastering Pandas Series helps you write clean and reliable Pandas code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
Pandas Series Code Example
Pandasimport pandas as pd
stock = pd.Series({"Laptop": 12, "Mouse": 150, "Monitor": 25})
print(stock)
print(stock["Mouse"])
print(stock[stock > 20])
Output
Laptop 12 Mouse 150 Monitor 25 dtype: int64 150 Mouse 150 Monitor 25 dtype: int64
Free sign-in required · Google login available
Pandas Series Practice Exercises
Check what you learned in “Pandas Series”.
/ 3 solved
Fill in the blank
Create a Series.
s = pd.([10, 20, 30])
✓ Correct!
Not quite. Try again.
Multiple choice
What does s.iloc[0] return?
✓ Correct!
Not quite. Try again.
Code challenge
Create a Series from {"a": 1, "b": 2, "c": 3} and print the value for "b".
Write the code in the live editor. Your answer is checked automatically.
✓ Solved
Free sign-in required · Google login available
to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.
Stuck on something?
Ask the community in the CodesInTech forum.
Need a developer?
Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.
Explore Our Services