0
0
Pandasdata~10 mins

info() for column types and nulls in Pandas - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - info() for column types and nulls
Create DataFrame
Call df.info()
Scan each column
Count non-null values
Identify data types
Print summary table
Show memory usage
The flow shows how calling info() scans each DataFrame column to count non-null values, identify data types, and then prints a summary with memory usage.
Execution Sample
Pandas
import pandas as pd

data = {'A': [1, 2, None], 'B': ['x', None, 'z']}
df = pd.DataFrame(data)
df.info()
This code creates a DataFrame with some nulls and calls info() to show column types and null counts.
Execution Table
StepActionColumnNon-null CountData TypeMemory Usage
1Create DataFrame----
2Call df.info()----
3Scan columnA2float64-
4Scan columnB2object-
5Print summary-A: 2 non-null B: 2 non-nullA: float64 B: objectApprox. 224 bytes
6Show memory usage---224 bytes
💡 All columns scanned and summary printed
Variable Tracker
VariableStartAfter df.info()
df{'A':[1,2,None],'B':['x',None,'z']}DataFrame with 2 columns, 3 rows, null counts shown
Key Moments - 2 Insights
Why does info() show fewer non-null counts than total rows?
Because info() counts only non-null (not missing) values per column, as seen in execution_table rows 3 and 4 where columns have 2 non-null out of 3 rows.
Why are some columns shown as 'object' type?
Columns with mixed or string data are shown as 'object' type, like column B in execution_table row 4.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the non-null count for column 'A' at step 3?
A3
B1
C2
D0
💡 Hint
Check the 'Non-null Count' column in execution_table row 3.
At which step does info() print the summary table?
AStep 5
BStep 4
CStep 2
DStep 6
💡 Hint
Look for 'Print summary' action in execution_table.
If column 'B' had no nulls, how would the non-null count change at step 4?
AIt would be 0
BIt would be 3
CIt would be 2
DIt would be 1
💡 Hint
Non-null count equals number of non-missing values; see variable_tracker for row count.
Concept Snapshot
df.info() shows a summary of DataFrame columns:
- Non-null counts per column
- Data types (e.g., float64, object)
- Memory usage
It helps quickly see missing data and column types.
Full Transcript
We start by creating a DataFrame with some missing values. When we call df.info(), pandas scans each column to count how many values are not missing. It also identifies the data type of each column, like float64 for numbers or object for text. Then it prints a summary table showing these counts and types, plus the memory used. This helps us understand the data structure and find missing values quickly.