How to Check the Data Type in Pandas DataFrame? Last Updated : 08 Sep, 2022 Comments Improve Suggest changes Like Article Like Report Pandas DataFrame is a Two-dimensional data structure of mutable size and heterogeneous tabular data. There are different Built-in data types available in Python. Two methods used to check the datatypes are pandas.DataFrame.dtypes and pandas.DataFrame.select_dtypes. Creating a Dataframe to Check DataType in Pandas DataFrame Consider a dataset of a shopping store having data about Customer Serial Number, Customer Name, Product ID of the purchased item, Product Cost, and Date of Purchase. Python3 #importing pandas as pd import pandas as pd # Create the dataframe df = pd.DataFrame({ 'Cust_No': [1,2,3], 'Cust_Name': ['Alex', 'Bob', 'Sophie'], 'Product_id': [12458,48484,11311], 'Product_cost': [65.25, 25.95, 100.99], 'Purchase_Date': [pd.Timestamp('20180917'), pd.Timestamp('20190910'), pd.Timestamp('20200610')] }) # Print the dataframe df Output: Check the Data Type in Pandas using pandas.DataFrame.dtypes For users to check the DataType of a particular Dataset or particular column from the dataset can use this method. This method returns a list of data types for each column or also returns just a data type of a particular column Example 1: Python3 # Print a list datatypes of all columns df.dtypes Output: Example 2: Python3 # print datatype of particular column df.Cust_No.dtypes Output: dtype('int64') Example 3: Python3 # Checking the Data Type of a Particular Column df['Product_cost'].dtypes Output: dtype('float64')Check the Data Type in Pandas using pandas.DataFrame.select_dtypes Unlike checking Data Type user can alternatively perform a check to get the data for a particular Datatype if it is existing otherwise get an empty dataset in return. This method returns a subset of the DataFrame’s columns based on the column dtypes. Example 1: Python3 # Returns Two column of int64 df.select_dtypes(include = 'int64') Output: Example 2: Python3 # Returns columns excluding int64 df.select_dtypes(exclude = 'int64') Output : Example 3 : Python3 # Print an empty list as there is # no column of bool type df.select_dtypes(include = "bool") Output : Comment More infoAdvertise with us Next Article How to Check the Data Type in Pandas DataFrame? A abhishekkharmale Follow Improve Article Tags : Python Python-pandas Python pandas-dataFrame Practice Tags : python Similar Reads How to Convert String to Float in Pandas DataFrame Converting Strings to Float in Pandas DataFrame is a very crucial step for data analysis. Converting string to float values can help you perform various arithmetic operations and plot graphs. In this article, we'll look at different ways to convert a string to a float in DataFrame. Creating Sample D 4 min read How to Change Column Type in PySpark Dataframe ? In this article, we are going to see how to change the column type of pyspark dataframe. Creating dataframe for demonstration: Python # Create a spark session from pyspark.sql import SparkSession spark = SparkSession.builder.appName('SparkExamples').getOrCreate() # Create a spark dataframe columns = 4 min read How to Convert String to Integer in Pandas DataFrame? Let's see methods to convert string to an integer in Pandas DataFrame: Method 1: Use of Series.astype() method. Syntax: Series.astype(dtype, copy=True, errors=âraiseâ) Parameters: This method will take following parameters: dtype: Data type to convert the series into. (for example str, float, int).c 3 min read How to Convert Floats to Strings in Pandas DataFrame? In this post, we'll see different ways to Convert Floats to Strings in Pandas Dataframe? Pandas Dataframe provides the freedom to change the data type of column values. We can change them from Integers to Float type, Integer to String, String to Integer, Float to String, etc. There are three methods 4 min read Change Data Type for one or more columns in Pandas Dataframe When working with data in Pandas working with right data types for your columns is important for accurate analysis and efficient processing. Pandas offers several simple ways to change or convert the data types of columns in a DataFrame. In this article, we'll look at different methods to help you e 3 min read Like