-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
float_format
in .to_string
can be str
#730
Comments
@twoertwein can you take a look at this? |
In the past, it apparently did not work. Since it works now, it probably is intended to pass formatting strings. Do you mind opening an issue at pandas to clarify the intend/update the docs? |
Issue that seems related: pandas-dev/pandas#9448 |
It still doesn't work for extension dtypes. pd.Series([1.1, 2.2, 3.3]).to_string(float_format="%.3e") # works
pd.Series([1.1, 2.2, 3.3]).convert_dtypes().to_string(float_format="%.3e") # `TypeError: 'str' object is not callable` |
Thank you, @zmoon ! In that case, I would be inclined to not add |
That seems fair until the docs are clarified and it works for extension dtypes too. Maybe we could leave this open though? |
Feel free to open also a new pandas issue to highlight the discrepancy with the extension types (and xref the existing issue about str/no str). edit: should we use the label "upstream issue" for this (and similar issues which first need to be confirmed/fixed in pandas)? |
Describe the bug
The change in #721 broke this for mypy. Although the current docs say "one-parameter function, optional, default None", you are allowed to pass a string that specifies the format like in
.to_csv
.To Reproduce
These usages all work with both frame and series.
Please complete the following information:
pandas-stubs
2.0.2.230605Additional context
Maybe
FloatFormatType
can be used (again) but could be updated to be more specific about the callable (Callable[[float], str]
).And perhaps the pandas docs should be updated? Unless support for passing format string was supposed to have been removed?
The text was updated successfully, but these errors were encountered: