0
0
Data Analysis Pythondata~10 mins

info() for column types in Data Analysis Python - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - info() for column types
Load DataFrame
Call df.info()
Scan each column
Count non-null values
Identify data type
Print summary table
Show memory usage
The info() method scans each column in the DataFrame, counts non-null values, identifies data types, and prints a summary including memory usage.
Execution Sample
Data Analysis Python
import pandas as pd

df = pd.DataFrame({
  'A': [1, 2, None],
  'B': ['x', 'y', 'z']
})

df.info()
This code creates a DataFrame with two columns and calls info() to show column types and non-null counts.
Execution Table
StepActionColumnNon-null CountData TypeMemory Usage
1Scan columnA2float6424 bytes
2Scan columnB3object72 bytes
3Calculate total memory---96 bytes
4Print summary table----
5End----
💡 All columns scanned and summary printed
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
non_null_counts{}{'A': 2}{'A': 2, 'B': 3}{'A': 2, 'B': 3}{'A': 2, 'B': 3}
data_types{}{'A': 'float64'}{'A': 'float64', 'B': 'object'}{'A': 'float64', 'B': 'object'}{'A': 'float64', 'B': 'object'}
memory_usage024969696
Key Moments - 2 Insights
Why does column 'A' show 2 non-null values instead of 3?
Because one value in column 'A' is None (missing), so info() counts only non-null entries as shown in execution_table rows 1 and 2.
What does the 'object' data type mean for column 'B'?
It means the column holds strings or mixed types; info() shows this as 'object' in execution_table row 2.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the non-null count for column 'B' at step 2?
A3
B2
C0
DNone
💡 Hint
Check the 'Non-null Count' column in execution_table row 2.
At which step is the total memory usage calculated?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look at the 'Memory Usage' column and the 'Action' column in execution_table.
If column 'A' had no missing values, how would the non-null count change at step 1?
AIt would be 0
BIt would be 3
CIt would be 2
DIt would be 'object'
💡 Hint
Refer to variable_tracker for 'non_null_counts' and how missing values affect counts.
Concept Snapshot
df.info() shows a summary of a DataFrame:
- Lists each column
- Shows non-null counts
- Shows data types
- Displays memory usage
Useful to quickly check data completeness and types.
Full Transcript
The info() method in pandas scans each column of a DataFrame to count how many values are not missing (non-null). It also identifies the data type of each column, such as float64 for numbers or object for strings. Then it prints a summary table showing these counts and types, along with the memory used by the DataFrame. For example, if a column has missing values, the non-null count will be less than the total rows. This helps understand the data structure and completeness quickly.