From d4fa62caf3c057b781bd39d621621656c4019189 Mon Sep 17 00:00:00 2001 From: JDkuba Date: Fri, 20 Mar 2020 14:43:03 +0100 Subject: [PATCH 1/2] TST: add test for non UTC datetime split --- .../tests/indexes/datetimes/test_datetime.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pandas/tests/indexes/datetimes/test_datetime.py b/pandas/tests/indexes/datetimes/test_datetime.py index 6217f225d496e..d61f6c5a8d19b 100644 --- a/pandas/tests/indexes/datetimes/test_datetime.py +++ b/pandas/tests/indexes/datetimes/test_datetime.py @@ -425,3 +425,22 @@ def test_index_map(self, name): ((2018,), range(1, 7)), names=[name, name] ) tm.assert_index_equal(index, exp_index) + + def test_split_non_utc(self): + indices = pd.date_range("2016-01-01 00:00:00+0200", freq="S", periods=10) + split_indices = np.split(indices, indices_or_sections=[]) + valid_indices = DatetimeIndex( + [ + "2016-01-01 00:00:00+02:00", + "2016-01-01 00:00:01+02:00", + "2016-01-01 00:00:02+02:00", + "2016-01-01 00:00:03+02:00", + "2016-01-01 00:00:04+02:00", + "2016-01-01 00:00:05+02:00", + "2016-01-01 00:00:06+02:00", + "2016-01-01 00:00:07+02:00", + "2016-01-01 00:00:08+02:00", + "2016-01-01 00:00:09+02:00", + ] + ) + tm.assert_index_equal(split_indices[0], valid_indices) From b6344ed6348c6a59c9bd2247d35eeb64e80841d9 Mon Sep 17 00:00:00 2001 From: JDkuba Date: Sat, 21 Mar 2020 14:17:11 +0100 Subject: [PATCH 2/2] TST: rename variable and issue no --- .../tests/indexes/datetimes/test_datetime.py | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/pandas/tests/indexes/datetimes/test_datetime.py b/pandas/tests/indexes/datetimes/test_datetime.py index d61f6c5a8d19b..12c4abe7a1b00 100644 --- a/pandas/tests/indexes/datetimes/test_datetime.py +++ b/pandas/tests/indexes/datetimes/test_datetime.py @@ -427,20 +427,9 @@ def test_index_map(self, name): tm.assert_index_equal(index, exp_index) def test_split_non_utc(self): + # GH 14042 indices = pd.date_range("2016-01-01 00:00:00+0200", freq="S", periods=10) - split_indices = np.split(indices, indices_or_sections=[]) - valid_indices = DatetimeIndex( - [ - "2016-01-01 00:00:00+02:00", - "2016-01-01 00:00:01+02:00", - "2016-01-01 00:00:02+02:00", - "2016-01-01 00:00:03+02:00", - "2016-01-01 00:00:04+02:00", - "2016-01-01 00:00:05+02:00", - "2016-01-01 00:00:06+02:00", - "2016-01-01 00:00:07+02:00", - "2016-01-01 00:00:08+02:00", - "2016-01-01 00:00:09+02:00", - ] - ) - tm.assert_index_equal(split_indices[0], valid_indices) + result = np.split(indices, indices_or_sections=[])[0] + expected = indices.copy() + expected._set_freq(None) + tm.assert_index_equal(result, expected)