8000 BUG: Fix type coercion in read_json orient='table' (#21345) by albertvillanova · Pull Request #25219 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix type coercion in read_json orient='table' (#21345) #25219

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 19 commits into from
Feb 23, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use pytest.raises
  • Loading branch information
Albert Villanova del Moral committed Feb 20, 2019
commit bf98bf8026b171693fc2fb054b96d2bd49978c4f
11 changes: 5 additions & 6 deletions pandas/tests/io/json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,14 +1209,13 @@ def test_from_json_to_json_table_dtypes(self):
result = pd.read_json(dfjson, orient='table')
assert_frame_equal(result, expected)

@pytest.mark.xfail(raises=ValueError)
@pytest.mark.parametrize('dtype', [True, False, {'b': int, 'c': int}])
def test_error_read_json_table_dtype(self, dtype):
def test_read_json_table_dtype_raises(self, dtype):
# GH21345
expected = pd.DataFrame({'a': [1, 2], 'b': [3., 4.], 'c': ['5', '6']})
dfjson = expected.to_json(orient='table')
result = pd.read_json(dfjson, orient='table', dtype=dtype)
assert_frame_equal(result, expected)
df = pd.DataFrame({'a': [1, 2], 'b': [3., 4.], 'c': ['5', '6']})
dfjson = df.to_json(orient='table')
with pytest.raises(ValueError):
pd.read_json(dfjson, orient='table', dtype=dtype)

@pytest.mark.parametrize('data, expected', [
(DataFrame([[1, 2], [4, 5]], columns=['a', 'b']),
Expand Down
0