Why Does Apply Change Dtype In Pandas Dataframe Columns
I have the following dataframe: import pandas as pd import numpy as np df = pd.DataFrame(dict(A = np.arange(3), B = np.random.randn(3),
Solution 1:
You can use parameter reduce=False
and more info here:
print (df.apply(lambda x: x.dtype, reduce=False))
Aint32Bfloat64CobjectDdatetime64[ns]dtype: object
In newer versions of pandas is possible use:
print (df.apply(lambda x: x.dtype, result_type='expand'))
Post a Comment for "Why Does Apply Change Dtype In Pandas Dataframe Columns"