-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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 3 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 |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
from pandas.io.json.table_schema import ( | ||
as_json_table_type, | ||
build_table_schema, | ||
parse_table_schema, | ||
convert_pandas_type_to_json_field, | ||
convert_json_field_to_pandas_type, | ||
set_default_names) | ||
|
@@ -86,6 +87,16 @@ def test_multiindex(self): | |
assert result == expected | ||
|
||
|
||
class TestParseSchema(object): | ||
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. Shouldn't need a new class here - can you just move this to |
||
|
||
def test_empty_json_data(self): | ||
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. Rename this to |
||
# GH21287 | ||
df = pd.DataFrame([], columns=['a', 'b', 'c']) | ||
json = df.to_json(None, orient='table') | ||
df = parse_table_schema(json, True) | ||
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. Let's use |
||
assert df.empty | ||
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. To make sure that we've preserved the frame metadata we should use the
|
||
|
||
|
||
class TestTableSchemaType(object): | ||
|
||
@pytest.mark.parametrize('int_type', [ | ||
|
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.
Explicitly reference :func:`read_json` and make sure to qualify that this only applies when ``orient='table'``
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 also update reference to :class:`DataFrame`