-
-
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 #25983
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 #25983
Conversation
Codecov Report
@@ Coverage Diff @@
## master #25983 +/- ##
==========================================
- Coverage 91.85% 91.84% -0.01%
==========================================
Files 175 175
Lines 52554 52556 +2
==========================================
- Hits 48272 48271 -1
- Misses 4282 4285 +3
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #25983 +/- ##
==========================================
- Coverage 91.86% 91.85% -0.01%
==========================================
Files 175 175
Lines 52547 52549 +2
==========================================
- Hits 48271 48268 -3
- Misses 4276 4281 +5
Continue to review full report at Codecov.
|
def test_to_html_formatters_object_type(): | ||
# GH 13021 | ||
def f(x): | ||
return x if type(x) is str else '${:,.0f}'.format(x) |
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.
Use isinstance instead of type
|
||
df = pd.DataFrame([['a'], [0], [10.4], [3]], columns=['x']) | ||
result = df.to_html(formatters=dict(x=f)) | ||
assert '$10' in result |
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 we make a better assertion here? I understand the original issue pertained to floats only but probably doesn't hurt to make an assertion around the other values here as well
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.
looks fine, ex @WillAyd comments, this fully replicates the original issue?
yes. |
lgtm. ping on green. |
green. but not all checks ran. needs a restart? |
hmm yeah, merge master and push again. |
gbq failure, otherwise good. |
yeah working on fixing gbq now |
thanks @simonjayhawkins |
I reverted this: fc5f292 as CI is failing |
git diff upstream/master -u -- "*.py" | flake8 --diff
can't shortcut completely without changing existing tested behaviour in a couple of tests.
for instance, the expected output for
test_to_string_with_formatters
inpandas\tests\io\formats\test_format.py
has two spaces between float and object column, whereas shortcuting would only have one (the same as between the int and float columns)if it's OK to change a couple of tests, we can remove this subtle leading_space bug in this PR.