Kontext Kontext / Code Snippets & Tips

Check Column Data Types in a Pandas DataFrame

event 2022-09-04 visibility 200 comment 0 insights
insights Stats

Code description

This code snippet provide examples of checking column data types in a DataFrame using dtype and dtypes.

Sample output:

>>> print(df.dtypes)
a     int64
b    object
dtype: object
>>> print(df.a.dtype)

Code snippet

import pandas as pd

data = {}
data['A'] = [1,2,3,4,5]
data['B'] = ['A','B','C','D','E']
df = pd.DataFrame(data)

# Check all column types

# Check data type of a certain column
More from Kontext
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts