python3 -c 'import pandas as pd; df=pd.read_csv("data.csv"); print(df[df.age > 30])'
Filter pandas rows where age exceeds 30
The expression df[df.age > 30] applies a boolean mask: pandas keeps only rows where the condition is true, here age greater than 30. The mask must reference the column with df.age or bracket notation. This is the pandas equivalent of a WHERE clause. Combine multiple conditions with the & operator and parentheses.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.