Pandas & Plotting
Filter, GroupBy, Merge
9 min+80 XPStep 1/10
Filter rows with a condition
Boolean masks work on DataFrames exactly like on arrays — the condition just reads like a query:
df[df['acc'] > 0.8]— keep the good modelsdf[(df['acc'] > 0.8) & (df['params'] < 1e6)]—&for and,|for or, parentheses mandatorydf.sort_values('acc', ascending=False)— rank the resultsdf['optimizer'].value_counts()— count each category
That first line is the most-typed pandas expression on Earth. Inside the brackets is the same boolean mask you used on NumPy arrays — df['acc'] > 0.8 produces a True/False per row, and df[...] keeps the Trues.