How to Get the Data Types of Each Columns in Pandas ?

Spread the love

To get the data types of each columns in pandas, we can use the dtype attribute of the pandas dataframe (pandas.DataFrame.dtypes). This returns a Series with the data type of each column.

Let’s read a dataset.

import pandas as pd

url = 'https://raw.githubusercontent.com/bprasad26/lwd/master/data/clothing_store_sales.csv'
df = pd.read_csv(url)
df.head()

Let’s use the dtypes attribute to get the Data types of each columns.

df.dtypes

Rating: 1 out of 5.

Leave a Reply