Skip to content

Commit 7a6a48b

Browse files
Add a regression test for the timezone issue
Add a regression test to ensure that the timezone doesn't get removed when using `df.apply`.
1 parent b372ac4 commit 7a6a48b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/indexing/test_datetime.py

+16
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,19 @@ def test_loc_label_slicing(self):
356356
expected = ser.iloc[:-1]
357357

358358
tm.assert_series_equal(result, expected)
359+
360+
def test_apply_datetime_tz_issue(self):
361+
# GH 29052
362+
363+
df = DataFrame(
364+
data=[0, 1, 2],
365+
index=[
366+
pd.Timestamp("2019-03-15 12:34:31.909000+0000", tz="UTC"),
367+
pd.Timestamp("2019-03-15 12:34:34.359000+0000", tz="UTC"),
368+
pd.Timestamp("2019-03-15 12:34:34.660000+0000", tz="UTC"),
369+
],
370+
)
371+
df2 = df.apply(lambda x: x.name, axis=1)
372+
373+
assert df[0].keys().dtype == df2.dtypes
374+
assert (df[0].keys().values == df2.values).all()

0 commit comments

Comments
 (0)