-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
to_html formatter not called for float values in a mixed-type column (2) #26000
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
to_html formatter not called for float values in a mixed-type column (2) #26000
Conversation
considering #24134 (comment) , this PR may need to revert some of #24134 which i think caused the regression in #25984 |
i'm going to close this for now, since while the implementation of |
Codecov Report
@@ Coverage Diff @@
## master #26000 +/- ##
=========================================
Coverage ? 91.86%
=========================================
Files ? 180
Lines ? 50717
Branches ? 0
=========================================
Hits ? 46592
Misses ? 4125
Partials ? 0
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #26000 +/- ##
==========================================
- Coverage 91.82% 91.82% -0.01%
==========================================
Files 175 175
Lines 52551 52555 +4
==========================================
+ Hits 48256 48257 +1
- Misses 4295 4298 +3
Continue to review full report at Codecov.
|
pandas/io/formats/format.py
Outdated
|
||
def get_result(self): | ||
fmt_values = self._format_strings() | ||
return _make_fixed_width(fmt_values, self.justify) | ||
|
||
def _format_strings(self): | ||
# shortcut | ||
if self.formatter is not None and self.shortcut: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need shortcut at all? isn't self.formatter is not None
enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the implementation of ExtensionArrayFormatter relies a formatter parameter and not shortcutting. so yes we need a shortcut parameter from to_string etc unless the ExtensionArrayFormatter implementation is changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather do that, this is too hacky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing the ExtensionArrayFormatter is unlikely to be trivial.
pandas/io/formats/format.py
Outdated
@@ -938,6 +938,10 @@ def get_result(self): | |||
return _make_fixed_width(fmt_values, self.justify) | |||
|
|||
def _format_strings(self): | |||
# shortcut |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you give some more explanation here
@simonjayhawkins can you merge master, what's the status? |
changing ExtensionArrayFormatter is necessary but outside the scope of this PR. did make a change here in this PR and ci passing. I think that is more an indication of missing tests than a solution. will do a precursor PR instead. I'm not really happy with the implementation of ExtensionArrayFormatter but don't know why it was done this way. There presumably needs to a mechanism for 3rd party creators of EA types to display a repr. not sure if this was the reason and that is the solution though. |
changed formatters to be a pre-formatter instead of a shortcut so this is no longer an issue. @jorisvandenbossche |
latest commit also closes #26002 (again), two spaces between columns now as for other DataFrame columns |
lgtm. @jorisvandenbossche @TomAugspurger if you want to have a look. |
@simonjayhawkins is this orthogonal to your formatters refactor? |
The two PRs are addressing orthogonal issues, but the implementations are not 100% orthogonal. The other PR is a more important issue. This PR addresses a case which is probably rarely encountered by users. This should probably be put on hold while the Extension Array formatting is discussed, since this PR does change some Extension Array formatting code. I could probably pull out a couple of these changes into a separate PR. Changing the formatter parameter to format_array to be optional is probably not contentious and adding a test for na_rep of IntegarNA would be a good thing. |
@simonjayhawkins there's a merge conflict. Is this ready for 0.25? Haven't had time to look at the change, but I'm happy to trust others if the tests are passing. |
i don't believe it is wise to merge this at this time, so closing for now and will revisit at a later date. |
git diff upstream/master -u -- "*.py" | flake8 --diff
resubmit of #25983