Skip to learning content

DATA SCIENCE PYTHON PLAYGROUND

Data Foundations · A little practice goes a long way.

← Inspect lessonsTINY TABLES · REAL PYTHON · YOUR PACE
Reading the whole table · I22 · 15 MIN

Inspect checkpoint

Task 1 · Follow the technique

Exercises within this concept

  1. Task 1Follow the techniqueCurrent exercise
  2. Task 2Profile a report population
  3. Task 3Answer a grouped inspection question
Task 1 · Messy café orders

Preserve df.

The editable setup on the right creates df. Run executes the setup and your work from top to bottom.

Your requirements

  1. Display a DataFrame with one row for each original column.
  2. Name its two columns dtype (data type as text) and missing (number of missing values).

Your inputs

Messy café orders · 8 synthetic rows
orderdrinksizepricetipdate
101" latte "LARGE6.2012026-06-01
102TEAsmall3.100.52026-06-02
103" mocha "LARGEoopsNonenot a date
104LatteSmallNone0.82026-06-04
104LatteSmallNone0.82026-06-04
105"tea "SMALL4.200.62026-06-05
106ESPRESSOsmall2.500.22026-06-06
107" mocha"large6.801.52026-06-07

Revisit the concept lesson →

Remember the idea

Concept sketch: column types and missing counts; original unchangednamepriceA2BNaNfielddtypemissnameobject0pricefloat641column types and missing counts; original unchanged

Inspect field quality before choosing records and summaries for a question.

A small example

A column-quality table puts each original field beside its storage type and missing count.

What each choice does
Code or choiceMeaning
df.dtypes.astype(str)Convert each dtype to text for the quality table.
df.isna().sum()Count missing entries in each field.
pd.DataFrame(...)Align the two Series by field name into one table.
Hint

Put each field on one row so its storage type and missing count can be checked together.

Reveal solution

One way to do it. Keep any supplied setup in the editor and use this in the Your work section.

pd.DataFrame(
    {
        "dtype": df.dtypes.astype(str),
        "missing": df.isna().sum(),
    }
)
Your task · Task 1
  1. Preserve df.
  2. Display a DataFrame with one row for each original column.
  3. Name its two columns dtype (data type as text) and missing (number of missing values).

Tab: indent · Shift+Tab: outdent · Esc, then Tab: leave editor

Edit Python. Control or Command plus Enter runs it. Tab indents by four spaces. Shift plus Tab outdents. Press Escape, then Tab or Shift plus Tab to leave the editor.

Each run executes all editor code in a fresh Python session. Display a value by leaving it on the final line.

Python starts when you open a lesson.

Output

Run your code to see what Python returns.