Python Practice › Pandas Programs › Program 61

Column data types

EasyPandas Programs · 61 of 95

Write a pandas program to get the data type of each column.

Advertisement
Output
name          str
age         int64
salary    float64
dtype: object

Approach

  1. dtypes.

Solution

Python
import pandas as pddf = pd.DataFrame({"name": ["Alex", "John"], "age": [30, 27], "salary": [50000.0, 65000.5]})print(df.dtypes)
Output
name          str
age         int64
salary    float64
dtype: object
Note

pandas 3 shows text columns as str; older versions show object.

Learn the concept

New to this topic? Read the lesson, then come back.

More pandas programs

← All 95 Pandas Programs

Leave a Comment