Selecting Pandas Columns by dtype

0 votes

I wanted to know if there is an elegant and shorthand way in Pandas DataFrames to select columns by data type (dtype). i.e. Select only int64 columns from a DataFrame.

For example, something like:

df.select_columns(dtype=float64)

Can anyone help me with this?

Jul 5, 2019 in Python by ana1504.k
• 7,910 points
1,106 views

1 answer to this question.

0 votes

You can use the following:

df.loc[:, df.dtypes == np.float64]
answered Jul 5, 2019 by SDeb
• 13,300 points

Related Questions In Python

0 votes
1 answer

How to filter Pandas DataFrame by values of columns?

Hi@akhtar, You can filter Pandas Dataframe with the ...READ MORE

answered Oct 20, 2020 in Python by MD
• 95,440 points
834 views
0 votes
1 answer

How can I reformat value_counts() analysis in Pandas for large number of columns?

If I were you, I'd do it ...READ MORE

answered Apr 17, 2018 in Python by anonymous
6,451 views
0 votes
1 answer

Reformat value_counts() analysis in Pandas for large number of columns

I'd do it this way: In [83]: df.drop('id',1).apply(lambda ...READ MORE

answered Sep 25, 2018 in Python by Priyaj
• 58,090 points
1,663 views
0 votes
1 answer
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,060 views
0 votes
1 answer
0 votes
1 answer

Python Pandas: selecting element in array column

pa.loc[row] selects the row with label row. pa.loc[row, ...READ MORE

answered May 13, 2019 in Python by SDeb
• 13,300 points
12,585 views
0 votes
1 answer

Round columns in pandas dataframe

You can now, use round on dataframe The code will ...READ MORE

answered Jul 4, 2019 in Python by SDeb
• 13,300 points
1,802 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP