1

I'm learning data science with the help of an online course. While learning about filtering specific datatype from a DataFrame object in Pandas, I came across this line of code:

df = df.select_dtypes(exclude=['object'])

The purpose of the module was to show how to get only numeric datatype. I'm not able to figure out what all things or data-types are included in the object type.

I tried to understand this from documentation given on Scipy Oficial

https://docs.scipy.org/doc/numpy-1.13.0/reference/arrays.dtypes.html

kuropan
  • 774
  • 7
  • 18
Deepam Gupta
  • 2,374
  • 1
  • 30
  • 33

3 Answers3

3

So basically, it will select all the columns except the columns with data type object.

References:

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
0

If you want to check the data type in pandas DataFrame columns, you can use the dtype attribute. If the output is dtype('0'), then it means that the values stored in that specific column are Python objects.

Please have a look at the following thread for further information: What is dtype('O'), in pandas?

M.H. Tajaddini
  • 776
  • 4
  • 20
AVO
  • 31
  • 3
-1

To include/exclude strings you may use the object dtype, it usually refers to string.