Python Practice › Pandas Programs › Program 16
Subset by condition
Write a pandas program to select the values below 40.
Input
[10, 25, 69, 74, 33, 54, 21]
Output
0 10 1 25 4 33 6 21 dtype: int64
Approach
- Boolean indexing.
Solution
import pandas as pds = pd.Series([10, 25, 69, 74, 33, 54, 21])print(s[s < 40])Output
0 10 1 25 4 33 6 21 dtype: int64
Learn the concept
New to this topic? Read the lesson, then come back.