Lesson 17 of 60 · python
Series: The One‑Dimensional Pandas Object
Duration: 15 minutes
Series Deep Dive
A Series is essentially a labeled array.
Creating Series from different sources
# From a list
s1 = pd.Series([100, 200, 300])
# From a dict (keys become index)
prices = {'apple': 0.99, 'banana': 0.5, 'cherry': 2.5}
s2 = pd.Series(prices)
print(s2)
Accessing elements
print(s2['banana']) # 0.5
print(s2.iloc[0]) # 0.99 (positional)
Vectorized operations
print(s2 * 1.1) # increase all prices by 10%
Handling missing data in Series
s3 = pd.Series([1, None, 3])
print(s3.isna())
print(s3.fillna(0))