Select Columns with Specific Data Types in Pandas Dataframe Last Updated : 23 May, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how to select columns with specific data types from a dataframe. This operation can be performed using the DataFrame.select_dtypes() method in pandas module. Syntax: DataFrame.select_dtypes(include=None, exclude=None)Parameters : include, exclude : A selection of dtypes or strings to be included/excluded. At least one of these parameters must be supplied.Return : The subset of the frame including the dtypes in include and excluding the dtypes in exclude. Step-by-step Approach: First, import modules then load the dataset. Python3 # import required module import pandas as pd # assign dataset df = pd.read_csv("train.csv") Then we will find types of data present in our dataset using dataframe.info() method. Python3 # display description # of the dataset df.info() Output: Now, we will use DataFrame.select_dtypes() to select a specific datatype. Python3 # store columns with specific data type integer_columns = df.select_dtypes(include=['int64']).columns float_columns = df.select_dtypes(include=['float64']).columns object_columns = df.select_dtypes(include=['object']).columns Finally, display the column having a particular data type. Python3 # display columns print('\nint64 columns:\n', integer_columns) print('\nfloat64 columns:\n', float_columns) print('\nobject columns:\n', object_columns) Output: Below is the complete program based on the above approach: Python3 # import required module import pandas as pd # assign dataset df = pd.read_csv("train.csv") # store columns with specific data type integer_columns = df.select_dtypes(include=['int64']).columns float_columns = df.select_dtypes(include=['float64']).columns object_columns = df.select_dtypes(include=['object']).columns # display columns print('\nint64 columns:\n',integer_columns) print('\nfloat64 columns:\n',float_columns) print('\nobject columns:\n',object_columns) Output: Example: Here we are going to extract columns of the below dataset: Python3 # import required module import pandas as pd from vega_datasets import data # assign dataset df = data.seattle_weather() # display dataset df.sample(10) Output: Now, we are going to display all the columns having float64 as the data type. Python3 # import required module import pandas as pd from vega_datasets import data # assign dataset df = data.seattle_weather() # display description # of dataset df.info() # store columns with specific data type columns = df.select_dtypes(include=['float64']).columns # display columns print('\nColumns:\n', columns) Output: Comment More infoAdvertise with us Next Article How to select multiple columns in a pandas dataframe I incredeble Follow Improve Article Tags : Python Python-pandas Python pandas-dataFrame Python Pandas-exercise Practice Tags : python Similar Reads How to Select Single Column of a Pandas Dataframe In Pandas, a DataFrame is like a table with rows and columns. Sometimes, we need to extract a single column to analyze or modify specific data. This helps in tasks like filtering, calculations or visualizations. When we select a column, it becomes a Pandas Series, a one-dimensional data structure th 2 min read How to Check the Data Type in Pandas DataFrame? 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 Dat 2 min read How to select multiple columns in a pandas dataframe Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier. In this article, we will discuss all the different ways of selecting multiple columns 5 min read Select a single column of data as a Series in Pandas In this article, we will discuss how to select a single column of data as a Series in Pandas. For example, Suppose we have a data frame : Name Age MotherTongue Akash 21 Hindi Ashish 23 Marathi Diksha 21 Bhojpuri Radhika 20 Nepali Ayush 21 Punjabi Now when we select column Mother Tongue as a Series w 1 min read Select rows that contain specific text using Pandas While preprocessing data using pandas dataframe there may be a need to find the rows that contain specific text. Our task is to find the rows that contain specific text in the columns or rows of a dataframe in pandas.Dataset in use:jobAge_RangeSalaryCredit-RatingSavingsBuys_HoneOwnMiddle-agedHighFai 4 min read Select columns in PySpark dataframe In this article, we will learn how to select columns in PySpark dataframe. Function used: In PySpark we can select columns using the select() function. The select() function allows us to select single or multiple columns in different formats. Syntax: dataframe_name.select( columns_names ) Note: We 4 min read Like