VOOZH about

URL: https://www.geeksforgeeks.org/python/select-columns-with-specific-data-types-in-pandas-dataframe/

⇱ Select Columns with Specific Data Types in Pandas Dataframe - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Select Columns with Specific Data Types in Pandas Dataframe

Last Updated : 23 Jul, 2025

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.
  • Then we will find types of data present in our dataset using dataframe.info() method.

Output:

👁 Image
👁 Image
👁 Image
  • Now, we will use DataFrame.select_dtypes() to select a specific datatype.
  • Finally, display the column having a particular data type.

Output:

👁 Image

Below is the complete program based on the above approach:

Output:

👁 Image

Example:

Here we are going to extract columns of the below dataset:

Output:

👁 Image

Now, we are going to display all the columns having float64 as the data type.

Output:

👁 Image
Comment