Chapter 4 · 6 levels

pandas first look

Meet the DataFrame. Open Harbor & Pine's real tables, check their size and types, pick columns and get quick summaries with value_counts and describe.

Start

From here on you work with the real Harbor & Pine data: 12,000 orders, 30,000 order lines, 2,000 customers, 120 products, and more. It’s far too much to loop over by hand, and that’s what pandas is for. pandas is the Python library analysts use for tables. It’s already imported as pd (and NumPy as np), and every table is preloaded as a DataFrame with the table’s name: orders, order_items, customers, products, returns, employees, web_sessions and marketing_spend.

The first thing a good analyst does with any new table is look at it. How many rows? What are the columns and their types? What values show up, and how often? Are there gaps? This chapter teaches that first look: head, shape, info, selecting columns, value_counts and describe. It sounds basic, but skipping it is how wrong numbers end up in front of a VP.

Levels

  1. Your first DataFrame

    from Priya Shah, Head of Data

    dataframe, series, index, head, tail

    Code Difficulty 1 of 5 Not started

  2. How big is the table?

    from Priya Shah, Head of Data

    shape, len, info, dtypes, columns

    Code Difficulty 1 of 5 Not started

  3. Pick the columns you need

    from Logan Brooks, Email Marketing Specialist

    column selection, series, dataframe, double brackets

    Code Difficulty 1 of 5 Not started

  4. Series or DataFrame?

    from Priya Shah, Head of Data

    series, dataframe, column selection

    Quiz Difficulty 2 of 5 Not started

  5. Count orders by status

    from Megan Collins, Head of Sales

    value counts, describe, nunique, unique

    Code Difficulty 2 of 5 Not started

  6. Boss: the first-look report

    from Priya Shah, Head of Data

    nunique, value counts, normalize, describe, round

    Boss · 3 steps Difficulty 3 of 5 Not started