CLN: cleanup json pandas tests coverage of datetime units - #66759
Open
jorisvandenbossche wants to merge 2 commits into
Open
CLN: cleanup json pandas tests coverage of datetime units#66759jorisvandenbossche wants to merge 2 commits into
jorisvandenbossche wants to merge 2 commits into
Conversation
Comment on lines
-550
to
-552
| index = date_range("20000101", periods=10, freq="h", unit="ns") | ||
| # freq doesn't round-trip | ||
| index = DatetimeIndex(list(index), freq=None) |
Member
Author
There was a problem hiding this comment.
This test is about a mixture of column dtypes, not need to also cover a datetime index (complicating the test further)
Comment on lines
-1377
to
+1354
| result = read_json(StringIO(ser.to_json()), typ="series").apply(converter) | ||
| tm.assert_series_equal(result, ser.astype("m8[ms]")) | ||
| result = read_json(StringIO(ser.to_json()), typ="series") | ||
| expected = ser.dt.as_unit("ms").astype("int64") |
Member
Author
There was a problem hiding this comment.
Creating an expected, instead of postprocessing the result to match the original data (more logical test structure)
Comment on lines
-1412
to
+1395
| result["a"] = pd.to_timedelta(result.a, unit="ns") | ||
| result["c"] = pd.to_datetime(result.c) | ||
| tm.assert_frame_equal(frame, result) | ||
| expected = frame.copy() | ||
| expected["a"] = expected["a"].dt.as_unit("ns").astype("int64") | ||
| expected["c"] = expected["c"].dt.as_unit("ns").astype("int64") | ||
| tm.assert_frame_equal(result, expected) |
Member
Author
There was a problem hiding this comment.
Same here, creating an expected, instead of postprocessing the result to match the original data (more logical test structure)
| assert result == expected | ||
|
|
||
| @pytest.mark.parametrize("as_object", [True, False]) | ||
| @pytest.mark.parametrize("timedelta_typ", [pd.Timedelta, timedelta]) |
Member
Author
There was a problem hiding this comment.
Unnecessary param: regardless of those two input types, that gets inferred as a timedelta64 series/index anyway
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While updating those tests in the PR changing the default unit (#65845), I thought those tests could use a cleanup (it will allow to simplify the tests a bit more in that PR):
unitwas not needed