From 9d694ff0c213e8cf5413ce9b2ff624f4f7f1ae63 Mon Sep 17 00:00:00 2001 From: BenjaminLiu Date: Fri, 3 Apr 2020 13:44:22 -0400 Subject: [PATCH 1/5] add test on date range timezone reindex --- pandas/tests/indexes/datetimes/test_date_range.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandas/tests/indexes/datetimes/test_date_range.py b/pandas/tests/indexes/datetimes/test_date_range.py index b8200bb686aad..1f7575d959d42 100644 --- a/pandas/tests/indexes/datetimes/test_date_range.py +++ b/pandas/tests/indexes/datetimes/test_date_range.py @@ -716,6 +716,16 @@ def test_date_range_with_tz(self, tzstr): assert stamp == rng[1] + def test_date_range_same_tz_reindex(self): + # GH 32740 + a = pd.date_range('2010-01-01', '2010-01-02', periods=24, tz='utc') + b = pd.date_range('2010-01-01', '2010-01-02', periods=23, tz='utc') + msg = ( + "date range convertion must have same timezone" + ) + with pytest.raises(ValueError, match=msg): + a.reindex(b, method='nearest', tolerance=timedelta(seconds=20)) + class TestGenRangeGeneration: def test_generate(self): From 54623910dc84a497a0a9dcab6fb71f8cf44197ff Mon Sep 17 00:00:00 2001 From: BenjaminLiu Date: Fri, 3 Apr 2020 13:47:06 -0400 Subject: [PATCH 2/5] undo --- pandas/tests/indexes/datetimes/test_date_range.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/indexes/datetimes/test_date_range.py b/pandas/tests/indexes/datetimes/test_date_range.py index 1f7575d959d42..5cd87070b2d7c 100644 --- a/pandas/tests/indexes/datetimes/test_date_range.py +++ b/pandas/tests/indexes/datetimes/test_date_range.py @@ -718,8 +718,8 @@ def test_date_range_with_tz(self, tzstr): def test_date_range_same_tz_reindex(self): # GH 32740 - a = pd.date_range('2010-01-01', '2010-01-02', periods=24, tz='utc') - b = pd.date_range('2010-01-01', '2010-01-02', periods=23, tz='utc') + a = date_range('2010-01-01', '2010-01-02', periods=24, tz='utc') + b = date_range('2010-01-01', '2010-01-02', periods=23, tz='utc') msg = ( "date range convertion must have same timezone" ) From b05b1089f9e1fbba4e7d42bb544aa3120302b640 Mon Sep 17 00:00:00 2001 From: BenjaminLiu Date: Fri, 3 Apr 2020 14:20:19 -0400 Subject: [PATCH 3/5] test 32776 --- pandas/tests/frame/test_constructors.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index 9f40e8c6931c8..1ee7f9a00393b 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -1345,6 +1345,12 @@ def test_constructor_tuple(self, tuples, lists): expected = DataFrame(lists) tm.assert_frame_equal(result, expected) + def test_constructor_tuple_of_lists(self): + # GH 32776 + result = DataFrame(tuple([[1], [2]])) + expected = DataFrame([[1], [2]]) + tm.assert_frame_equal(result, expected) + def test_constructor_list_of_tuples(self): result = DataFrame({"A": [(1, 2), (3, 4)]}) expected = DataFrame({"A": Series([(1, 2), (3, 4)])}) From 237bcae0fa9d3106f589eee0435b24b8bde3b6f0 Mon Sep 17 00:00:00 2001 From: BenjaminLiu Date: Fri, 3 Apr 2020 14:26:21 -0400 Subject: [PATCH 4/5] undo --- pandas/tests/indexes/datetimes/test_date_range.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pandas/tests/indexes/datetimes/test_date_range.py b/pandas/tests/indexes/datetimes/test_date_range.py index 5cd87070b2d7c..b8200bb686aad 100644 --- a/pandas/tests/indexes/datetimes/test_date_range.py +++ b/pandas/tests/indexes/datetimes/test_date_range.py @@ -716,16 +716,6 @@ def test_date_range_with_tz(self, tzstr): assert stamp == rng[1] - def test_date_range_same_tz_reindex(self): - # GH 32740 - a = date_range('2010-01-01', '2010-01-02', periods=24, tz='utc') - b = date_range('2010-01-01', '2010-01-02', periods=23, tz='utc') - msg = ( - "date range convertion must have same timezone" - ) - with pytest.raises(ValueError, match=msg): - a.reindex(b, method='nearest', tolerance=timedelta(seconds=20)) - class TestGenRangeGeneration: def test_generate(self): From 72955b9255c3b106e96d0bfc7dd33f8fb435b510 Mon Sep 17 00:00:00 2001 From: BenjaminLiu Date: Sat, 4 Apr 2020 13:06:04 -0400 Subject: [PATCH 5/5] black --- pandas/tests/frame/test_constructors.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index 1ee7f9a00393b..fcdc62753ca0a 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -1336,6 +1336,7 @@ def test_constructor_mixed_type_rows(self): (((), ()), [(), ()]), (((), ()), [[], []]), (([], []), [[], []]), + (([1], [2]), [[1], [2]]), # GH 32776 (([1, 2, 3], [4, 5, 6]), [[1, 2, 3], [4, 5, 6]]), ], ) @@ -1345,12 +1346,6 @@ def test_constructor_tuple(self, tuples, lists): expected = DataFrame(lists) tm.assert_frame_equal(result, expected) - def test_constructor_tuple_of_lists(self): - # GH 32776 - result = DataFrame(tuple([[1], [2]])) - expected = DataFrame([[1], [2]]) - tm.assert_frame_equal(result, expected) - def test_constructor_list_of_tuples(self): result = DataFrame({"A": [(1, 2), (3, 4)]}) expected = DataFrame({"A": Series([(1, 2), (3, 4)])})