-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: float formatters ignore nullable floating extension type #39336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks @MaxSchambach for the report the new experimental FloatingArray, introduced in 1.2 https://pandas.pydata.org/docs/whatsnew/v1.2.0.html#experimental-nullable-data-types-for-float-data and still some work to be done #38110 (including Honor the formatting options (eg precision)) |
Thanks for the quick response! |
This is indeed still a missing feature in the new float dtype. Also the nullable integer dtype has the same problem (but it's something you will typically do more often with floats, for sure) Note that the full
|
Yes that is true. To be fair, I have not used the |
Out of curiosity, can I ask why you were using the |
Well that's a good point! |
Yes, due to the name "convert_dtypes", that's a logical thing to think. But, the method is not meant to generally convert object dtypes, but specifically to convert normal dtypes to the nullable dtypes (so if you explicitly want to use/test those experimental data types). For inferring object type (exactly for the use case that you describe), there is the (we had a long discussion about the name when the method was added, I personally find it confusing and not explicit, but unfortunately I lost the debate ;)) |
Aha, yes I see! And thanks for the hint, I will update my usage of |
Problem description
Pandas float formatters ignore the nullable floating extension types
Float64
which was introduced with 1.2.0.In particular, this is extremely confusing when using
DataFrame.convert_dtypes
since the default is now withconvert_floating=True
which converts all float colums toFloat64
columns.That is, the following does not produce the expected float formatting:
gives
I am not sure, whether this classifies as a bug or missing documentation (or both) however having not heard of this new nullable floating type
Float64
I did not notice this subtle difference at first. Also, I did not expectDataFrame.convert_dtypes()
to result in a non-formatableDataFrame
. So, ifFloat64
is not expected to format asfloat64
, the documentation should make this clear.However, I believe the best would be that
Float64
formats just as the regular float dtype.Expected Output
The formatting should be applied to the
Float64
dtype just as when using thefloat
dtype such aswhich gives
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: