Skip to content

Commit 054b31b

Browse files
authored
TST: added test for groupby/apply timezone-aware with copy (#35225)
1 parent 12086b3 commit 054b31b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/groupby/test_apply.py

+15
Original file line numberDiff line numberDiff line change
@@ -995,3 +995,18 @@ def test_apply_function_with_indexing_return_column():
995995
result = df.groupby("foo1", as_index=False).apply(lambda x: x.mean())
996996
expected = DataFrame({"foo1": ["one", "three", "two"], "foo2": [3.0, 4.0, 4.0]})
997997
tm.assert_frame_equal(result, expected)
998+
999+
1000+
def test_apply_with_timezones_aware():
1001+
# GH: 27212
1002+
1003+
dates = ["2001-01-01"] * 2 + ["2001-01-02"] * 2 + ["2001-01-03"] * 2
1004+
index_no_tz = pd.DatetimeIndex(dates)
1005+
index_tz = pd.DatetimeIndex(dates, tz="UTC")
1006+
df1 = pd.DataFrame({"x": list(range(2)) * 3, "y": range(6), "t": index_no_tz})
1007+
df2 = pd.DataFrame({"x": list(range(2)) * 3, "y": range(6), "t": index_tz})
1008+
1009+
result1 = df1.groupby("x", group_keys=False).apply(lambda df: df[["x", "y"]].copy())
1010+
result2 = df2.groupby("x", group_keys=False).apply(lambda df: df[["x", "y"]].copy())
1011+
1012+
tm.assert_frame_equal(result1, result2)

0 commit comments

Comments
 (0)