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 in Python by ana1504.k
• 7,890 points
182 views

1 answer to this question.

0 votes

You can use the following:

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

Related Questions In Python

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
2,537 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
• 56,940 points
443 views
0 votes
0 answers

how do sort the columns in a dataframe using the pandas?

can you give an example using dataframe? READ MORE

May 6 in Python by Waseem
• 4,470 points
25 views
+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 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 348 views
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 in Python by SDeb
• 13,190 points
70 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 in Python by SDeb
• 13,190 points
82 views