Selecting, cleaning and transforming
Selecting with loc, iloc and masks, finding and handling missing values, and creating and recoding columns.
About 6 hours of study
Learning objectives
- Select rows and columns by label, position and condition
- Count, fill and drop missing values
- Create, map and bin columns
Lessons
- 1
Selecting rows and columns: loc, iloc and masks Intermediate
Choosing parts of a DataFrame by label with loc, by position with iloc, and by condition with boolean masks combined with &, | and ~, plus assigning values through a selection.
- 2
Missing data: finding, dropping and filling Intermediate
How pandas marks missing values with NaN and None, counting them with isna, how statistics skip them, and the two ways to deal with them: dropping rows with dropna or filling with fillna, ffill and bfill.
- 3
Transforming columns Intermediate
Creating and changing columns: arithmetic between columns, assign, map with a dictionary, apply with a function, astype, rename and drop, and binning numbers into categories with cut.
Module practice
- pandas: Slices with loc and ilocEasy
- pandas: Filter rows with combined masksMedium
- pandas: Change values through locHard
- pandas: Count the missing valuesEasy
- pandas: Fill gaps column by columnMedium
- pandas: dropna with how, subset and threshHard
- pandas: Add a computed columnEasy
- pandas: Map codes to namesMedium
- pandas: Bin numbers with cutHard