Skip to content

Commit 7415fc6

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 7415fc6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/indexing/test_datetime.py

+15
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,18 @@ 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+
timestamps = [
364+
pd.Timestamp("2019-03-15 12:34:31.909000+0000", tz="UTC"),
365+
pd.Timestamp("2019-03-15 12:34:34.359000+0000", tz="UTC"),
366+
pd.Timestamp("2019-03-15 12:34:34.660000+0000", tz="UTC"),
367+
]
368+
df = DataFrame(data=[0, 1, 2], index=timestamps)
369+
result = df.apply(lambda x: x.name, axis=1)
370+
expected = pd.Series(index=timestamps, data=timestamps)
371+
372+
tm.assert_series_equal(result, expected)
373+

0 commit comments

Comments
 (0)