Stage 1 · Lesson 4 of 7
Selecting columns and filtering rows
Most questions start by narrowing the data to the rows and columns that matter, such as paid orders from the last quarter. In you use loc with a boolean mask, a series of True and False values, and a list of column names. In dplyr you use filter and select.
Combine conditions with and, or and not, and learn helpers for ranges, lists of allowed values and text patterns. Write down in plain words which your defines, because every number you report later describes only that group.
A filter on a column with missing values also drops those rows silently in either language.
Common trapThe trap is, in pandas, writing and instead of & or forgetting the brackets around each condition, which raises an error or, worse, filters on the wrong thing.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with
- BookFreeR for Data Science (2e)
Wickham, Çetinkaya-Rundel, Grolemund · Beginner
Free online: the Whole game and Transform chapters teach the tidyverse verbs in the order you need them