I'm trying to merge two dataframes in Pandas. One of the dataframes has a numerical column whose type is "int64"
However, after the merge, the type is switched to "float64" for some reason. Note that this is not my join column
When I try to access the dataframe, it errors out:
In [56]: account_aggregates.head()
Out[56]: ) failed: TypeError: %d format: a number is required, not numpy.float64>
The reason that the dtype is changed to float64 is because missing values NaN cannot be represented using integer.
With respect to the error message, I had a hunch that it was 'display.float_format' as I answered a question earlier today on this and saw this error. I think that it's because you have to pass a str.format as the value rather than a format string:
pd.set_option('display.float_format', '{:.2g}'.format) as opposed to pd.set_option('display.float_format', '%.2g') as an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With