From 3685fd54f933e4c7279615f5c463c214a02eac75 Mon Sep 17 00:00:00 2001 From: Tan Tran <42478131+tranctan@users.noreply.github.com> Date: Wed, 11 Dec 2019 18:21:30 +0700 Subject: [PATCH] TST: DataFrameGroupBy.shift Loses TimeZone in datetime64 columns (#30153) --- pandas/tests/groupby/test_groupby.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/tests/groupby/test_groupby.py b/pandas/tests/groupby/test_groupby.py index 3a16642641fca3..93d4dc6046735a 100644 --- a/pandas/tests/groupby/test_groupby.py +++ b/pandas/tests/groupby/test_groupby.py @@ -1702,6 +1702,15 @@ def test_group_shift_with_fill_value(): tm.assert_frame_equal(result, expected) +def test_group_shift_lose_timezone(): + # GH 30134 + now_dt = pd.Timestamp.utcnow() + df = DataFrame({"a": [1, 1], "date": now_dt}) + result = df.groupby("a").shift(0).iloc[0] + expected = Series({"date": now_dt}, name=result.name) + tm.assert_series_equal(result, expected) + + def test_pivot_table_values_key_error(): # This test is designed to replicate the error in issue #14938 df = pd.DataFrame(