Skip to content

Cleaned up JSON test with ambiguous DTA usage #28502

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 1 commit into from
Sep 18, 2019
Merged
Changes from all commits
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
26 changes: 15 additions & 11 deletions pandas/tests/io/json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,20 +813,11 @@ def test_series_roundtrip_simple(self, orient, numpy):
@pytest.mark.parametrize("dtype", [False, None])
@pytest.mark.parametrize("numpy", [True, False])
def test_series_roundtrip_object(self, orient, numpy, dtype):
# TODO: see why tm.makeObjectSeries provides back DTA
dtSeries = Series(
[str(d) for d in self.objSeries],
index=self.objSeries.index,
name=self.objSeries.name,
)
data = dtSeries.to_json(orient=orient)
data = self.objSeries.to_json(orient=orient)
result = pd.read_json(
data, typ="series", orient=orient, numpy=numpy, dtype=dtype
)
if dtype is False:
expected = dtSeries.copy()
else:
expected = self.objSeries.copy()
expected = self.objSeries.copy()

if not numpy and PY35 and orient in ("index", "columns"):
expected = expected.sort_index()
Expand Down Expand Up @@ -897,6 +888,19 @@ def test_series_with_dtype(self):
expected = Series([4] * 3)
assert_series_equal(result, expected)

@pytest.mark.parametrize(
"dtype,expected",
[
(True, Series(["2000-01-01"], dtype="datetime64[ns]")),
(False, Series([946684800000])),
],
)
def test_series_with_dtype_datetime(self, dtype, expected):
s = Series(["2000-01-01"], dtype="datetime64[ns]")
data = s.to_json()
result = pd.read_json(data, typ="series", dtype=dtype)
assert_series_equal(result, expected)

def test_frame_from_json_precise_float(self):
df = DataFrame([[4.56, 4.56, 4.56], [4.56, 4.56, 4.56]])
result = read_json(df.to_json(), precise_float=True)
Expand Down