Data Inspection Command Center
Run the Data Inspection Command Center MicroSim Fullscreen
Edit in the p5.js Editor
About This MicroSim
The left panel holds a DataFrame df of eight students with five columns. One age and one score are missing. The right panel is a notebook cell: the command you chose and the output pandas gives for it, with a note on how to read that output. Seven commands are available:
df.head(n)anddf.tail(n): the first or last n rowsdf.shape: the pair (rows, columns)df.info(): column names, non-null counts, data types, and memory usedf.describe(): summary statistics for the numeric columnsdf.columnsanddf.dtypes: the column names, and the data type of each column
The table is highlighted to show what each command looked at, for example the first n rows for head, the numeric columns for describe, and the NaN cells for info.
Every output is computed from the table. describe() uses the sample standard deviation and linearly interpolated quartiles, as pandas does, and the outputs were checked against pandas 2.3. Text columns have the dtype object, as in the chapter. From pandas 3 on they are labeled str instead.
How to Use
- Pick a command from the Command menu. The notebook cell shows the code and its output.
- For
df.head(n)anddf.tail(n), drag the Rows n slider from 1 to 8 and watch which rows are highlighted indf. - Before choosing
df.shape,df.columns, ordf.dtypes, predict the output from the table, then check. - Choose
df.info()and find the two columns whose non-null count is below 8. Find the matching NaN cells in the table. - Choose
df.describe()and work out which columns are missing from the output, and why.
Iframe Embed Code
You can add this MicroSim to any web page by adding this to your HTML:
1 2 3 4 | |
Lesson Plan
Grade Level
High School (11-12) and College Freshman
Duration
10-15 minutes
Prerequisites
The parts of a DataFrame, loading a CSV file with read_csv, and the meaning of mean and quartiles.
Bloom's Taxonomy Level
Apply (L3)
Learning Objective
Students will be able to use head, tail, shape, info, describe, columns, and dtypes to inspect a DataFrame and interpret each output, including finding missing values from the non-null counts.
Activities
- Predict and check (5 min): For shape, columns, and dtypes, students write the output they expect from the table before selecting the command.
- Head and tail (4 min): Students set n to 3 and compare head with tail, then find the smallest n for which head shows a NaN.
- Find the missing data (6 min): Using info() and describe(), students state how many values are missing in each column and explain why count is 7 rather than 8.
Assessment
Students are shown the info() output from the chapter (1000 entries, four columns). They state the shape of the DataFrame, name the columns with missing values and how many are missing in each, and say which columns describe() would summarize.
References
- pandas documentation. Essential basic functionality.
- pandas documentation. pandas.DataFrame.info.
- pandas documentation. pandas.DataFrame.describe.