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

Lessons

  1. 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. 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. 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

Module quiz

1. Which how keeps every row of the left table?
2. Which accessor gives string methods for a column?
3. What does pd.to_datetime(s, errors='coerce') give for 'not a date'?
4. What does validate='many_to_one' check?
5. Why pass na=False to str.contains in a filter?
6. Why might resample show a month that groupby on a month column does not?

‹ Summarising and reshapingpandas in practice ›