When I write
print(set(df_.dtypes))
I'm getting:
{dtype('int64'), dtype('float64')}
Is it possible to get the result like:
int64, float64 or [int64, float64]?
When I write
print(set(df_.dtypes))
I'm getting:
{dtype('int64'), dtype('float64')}
Is it possible to get the result like:
int64, float64 or [int64, float64]?
Yes you can
set(df.dtypes.map(lambda x : x.name))
Out[379]: {'float64', 'int64', 'object'}
You can try:
str(df_.dtypes).split()[1::2][:-1]
Explanations:
df_.dtypes : get the types of each columnsstr(df_.dtypes): convert the previous results to string.split() : split the string by space[1::2] : select every 2 elements of the list (starting at 1)[:-1] : remove the last element of the list (useless here)You might use df.dtypes
df=pd.DataFrame()
df['A']=['a','b','c']
df['B']=[1,2,3]
df['C']=[1.3,4.6,0.01]
print(df.dtypes)
output:
A object
B int64
C float64
dtype: object