linux
linux

Reputation: 157

How to get only the datatypes of df in python?

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

Upvotes: 0

Views: 53

Answers (1)

Denny Chen
Denny Chen

Reputation: 499

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 ]

Upvotes: 3

Related Questions