Home > database >  How to get only the datatypes of df in python?
How to get only the datatypes of df in python?

Time:02-25

Using df.dtypes on my df gives me:

AccountKey                         int64
ParentAccountKey                 float64
AccountCodeAlternateKey            int64

I only need the datatypes, and not the column names. How to get this?

I want to achieve something like this :

 if datatypes contain 'varchar':
       flag = 1

CodePudding user response:

The output of df.dtpyes is a Series, just extract the values part.

df.dtypes.values

For the thing you want to achieve :

flag = [1 if x == "O" else 0 for x in df.dtypes.values ]
  • Related