-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Don't ignore na_rep in DataFrame.to_html #36690
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
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
e1614ae
BUG: Don't ignore na_rep in DataFrame.to_html
dsaxton f56d893
Back to list
dsaxton 247e79b
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton f33e4d0
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton e83b7ed
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton a240b49
Move test and cover
dsaxton 7ee3ef2
Test for to_latex
dsaxton 72a812a
More tests
dsaxton ca57e06
Maybe
dsaxton dd25388
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton 4a599b2
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton dc6287a
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton faa8e2c
Note
dsaxton 1374cdd
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton c81aa04
Refactor
dsaxton 52f16fc
Move note
dsaxton 8c46ab7
Nothing
dsaxton 6cb161c
Fixup
dsaxton b166ffc
Remove
dsaxton 199c560
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton 5a054d7
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton 4423dd7
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton 0c49eb0
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton 4b53c91
Doc
dsaxton 87c172a
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton 265e2a8
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton 8f0ca15
Type
dsaxton 7be7c38
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton 5a50ad0
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton 1af22a5
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton 37cc78c
Merge remote-tracking branch 'upstream/master' into na_rep-with-float…
dsaxton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -820,3 +820,38 @@ def test_html_repr_min_rows(datapath, max_rows, min_rows, expected): | |
with option_context("display.max_rows", max_rows, "display.min_rows", min_rows): | ||
result = df._repr_html_() | ||
assert result == expected | ||
|
||
|
||
@pytest.mark.parametrize("na_rep", ["NaN", "Ted"]) | ||
def test_to_html_na_rep_and_float_format(na_rep): | ||
# https://github.com/pandas-dev/pandas/issues/13828 | ||
df = DataFrame( | ||
[ | ||
["A", 1.2225], | ||
["A", None], | ||
], | ||
columns=["Group", "Data"], | ||
) | ||
result = df.to_html(na_rep=na_rep, float_format="{:.2f}".format) | ||
expected = f"""<table border="1" class="dataframe"> | ||
<thead> | ||
<tr style="text-align: right;"> | ||
<th></th> | ||
<th>Group</th> | ||
<th>Data</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<th>0</th> | ||
<td>A</td> | ||
<td>1.22</td> | ||
</tr> | ||
<tr> | ||
<th>1</th> | ||
<td>A</td> | ||
<td>{na_rep}</td> | ||
</tr> | ||
</tbody> | ||
</table>""" | ||
assert result == expected | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for html tests, can use expected_html fixture. see test_to_html_justify for usage as template. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 use this function more generally? (e.g. maybe define it in the module); can be a followup 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.
It seems similar patterns occur elsewhere, although most are at the scalar level