Skip to content

TST: add read_json test #GH32383 #33345

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 12 commits into from
Apr 12, 2020
18 changes: 18 additions & 0 deletions pandas/tests/io/json/test_json_table_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,24 @@ def test_build_series(self):

assert result == expected

def test_read_json_from_to_json_results(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add both of the construction methods from the OP.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I am confused. Can you elaborate more?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the second construction will always work, is it necessary to add a test here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about now?

# GH 32383
df = pd.DataFrame(
{
"_id": {"0": "0"},
"category": {"0": "Goods"},
"recommender_id": {"0": "3"},
"recommender_name_jp": {"0": "浦田"},
"recommender_name_en": {"0": "Urata"},
"name_jp": {"0": "博多人形(松尾吉将まつお よしまさ)"},
"name_en": {"0": "Hakata Dolls Matsuo"},
}
)
df_json = df.to_json()
result = pd.read_json(df_json)
result.index = result.index.astype(str)
tm.assert_frame_equal(result, df)

def test_to_json(self):
df = self.df.copy()
df.index.name = "idx"
Expand Down