Cheatsheet 1
In pandas, there are a few quick + reliable ways to check the data type of columns, depending on what you need.
1️⃣ Check all column types (most common)
Output example
2️⃣ Detailed overview (very useful for debugging)
df.info()
Shows:
-
column name
-
non-null count
-
dtype
-
memory usage
3️⃣ Check type of a single column
or
4️⃣ Check only numeric / non-numeric columns
5️⃣ Check if a column is a specific type
6️⃣ Count how many columns per dtype
7️⃣ Detect mixed or problematic types (object columns)
Useful when:
-
CSV imported badly
-
numbers stored as strings
-
mixed types in one column
| Task | Command |
|---|---|
| See all dtypes | df.dtypes |
| Full summary | df.info() |
| Single column | df[col].dtype |
| Only numeric | select_dtypes() |
| Type check |
|
No Comments