Python Practice › Pandas Programs › Program 61
Column data types
Write a pandas program to get the data type of each column.
Output
name str age int64 salary float64 dtype: object
Approach
dtypes.
Solution
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.