0
0
Pandasdata~3 mins

Why info() for column types and nulls in Pandas? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

Discover how a single command can save you hours of tedious data checking!

The Scenario

Imagine you have a big spreadsheet with hundreds of columns and thousands of rows. You want to quickly understand what kind of data each column holds and if there are missing values, but you have to open each column one by one and scan through the data manually.

The Problem

This manual checking is slow and tiring. You might miss some missing values or misunderstand the data type, leading to mistakes later. It's like trying to find a needle in a haystack without a magnet.

The Solution

The info() function in pandas gives you a quick summary of your data. It shows the type of each column and how many non-missing values it has, all in one place. This saves time and helps you spot problems early.

Before vs After
Before
print(df['age'].dtype)
print(df['age'].isnull().sum())
After
df.info()
What It Enables

With info(), you can instantly see the health and structure of your data, making it easier to clean and analyze.

Real Life Example

A data analyst receives a messy sales dataset and uses info() to quickly find columns with missing prices or wrong data types before starting any calculations.

Key Takeaways

Manually checking data types and missing values is slow and error-prone.

info() provides a fast, clear summary of column types and null counts.

This helps you understand and clean your data efficiently.