Combining tables, text and dates
Merging and stacking tables with checks, cleaning and extracting text with the .str accessor, and parsing and resampling dates.
About 6 hours of study
Learning objectives
- Merge tables and audit the result
- Clean and parse text columns
- Work with dates, durations and periods
Lessons
- 1
Merging and joining DataFrames Intermediate
Combining tables in pandas: pd.merge with inner, left, right and outer joins, keys with different names, suffixes, the indicator column, validate for catching duplicate keys, concat for stacking, and join on the index.
- 2
Working with text columns Intermediate
Cleaning and analysing text in pandas with the .str accessor: case, spaces and replacements, contains and startswith with case and missing values, split and expand, and pulling structured fields out of codes with str.extract and regular expressions.
- 3
Dates and times in pandas Intermediate
Working with dates in pandas: parsing with to_datetime and errors="coerce", the .dt accessor for years, months and day names, date differences as Timedeltas, and resampling a series to monthly totals with empty months filled.
Module practice
- pandas: Stack two tables with concatEasy
- pandas: Inner, left and outer mergesMedium
- pandas: A checked many-to-one mergeHard
- pandas: Normalise namesEasy
- pandas: Filter rows by a keywordMedium
- pandas: Extract fields from codesHard
- pandas: Year, month and day nameEasy
- pandas: Delivery times in daysMedium
- pandas: Monthly totals with resampleHard