python - Pandas reporting series to be an object when it's a decimal -
i need automated reliable way find data type of each column in pandas data frame. have been using .dtype() have noticed unexpected it.
consider 10 row data frame:
df['a'] out[6]: 0 250.00 1 750.00 2 0.00 3 0.00 4 0.00 5 0.00 6 0.00 7 0.00 8 0.00 9 0.00 name: a, dtype: object type(df['a'][0]) out[9]: decimal.decimal why dtype of entire column 'object' when each entry decimal? need decimal or float or numeric. appreciated!
this not error due numpy dtype representation: https://docs.scipy.org/doc/numpy/reference/arrays.scalars.html.
basically decimal not principle inbuilt type it's dtype ends being object though actual type of each cell still decimal.
it's advised possible use inbuilt scalar types, in case float64, because arithmetic operations unlikely vectorised though type may numerical.
the same observed when store str or datetime.date values, dtype object these.
Comments
Post a Comment