-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix empty Data frames to JSON round-trippable back to data frames #21318
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
Changes from 13 commits
6dfd976
466e5a6
db3a738
5844301
fd8fa93
2f347c0
28d6e05
743c08f
833afea
2461b90
03a2b8a
fc15ba0
0a26bf8
ecc631a
8d5f127
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -560,3 +560,16 @@ def test_multiindex(self, index_names): | |||
out = df.to_json(orient="table") | ||||
result = pd.read_json(out, orient="table") | ||||
tm.assert_frame_equal(df, result) | ||||
|
||||
@pytest.mark.parametrize("strict_check", [ | ||||
pytest.param(True, marks=pytest.mark.xfail), False]) | ||||
def test_empty_frame_roundtrip(self, strict_check): | ||||
# GH 21287 | ||||
df = pd.DataFrame([], columns=['a', 'b', 'c']) | ||||
expected = df.copy() | ||||
out = df.to_json(orient='table') | ||||
result = pd.read_json(out, orient='table') | ||||
# TODO: When DF coercion issue (#21345) is resolved tighten type checks | ||||
tm.assert_frame_equal(expected, result, | ||||
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. Minor nit but can you parametrize this with a "strict_check" parameter whose values can be
The explicit xfail gives more visibility to the issue (I'm being overly cautious here) 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. Sure, I’ll make the change. Have to say that I appreciate your pedantics on these! 😊 |
||||
check_dtype=strict_check, | ||||
check_index_type=strict_check) |
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 is this showing up in the diff?
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.
Yeah, just noticed the same. Should not be there, sry
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.
No worries! Merging branches can surprise you sometimes 😄
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.
there was a removed newline, fixed
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.
Great, thanks! I did not have chance to fix it during the weekend, but great that it was resolved already.