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,890 points
231 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,230 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
3,302 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
• 57,530 points
601 views
0 votes
1 answer
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, 2019 in Python by Waseem
• 4,520 points
52 views
0 votes
1 answer
+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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 672 views
0 votes
0 answers
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,230 points
223 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,230 points
273 views