Skip to content

Commit 8b56ea3

Browse files
mroeschkejreback
authored andcommitted
BUG: Datetime.update with tz-aware date doesn't return naive data (#25810)
1 parent 0bf9f14 commit 8b56ea3

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

doc/source/whatsnew/v0.25.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ Timezones
212212
- Bug in :func:`to_datetime` with ``utc=True`` and datetime strings that would apply previously parsed UTC offsets to subsequent arguments (:issue:`24992`)
213213
- Bug in :func:`Timestamp.tz_localize` and :func:`Timestamp.tz_convert` does not propagate ``freq`` (:issue:`25241`)
214214
- Bug in :func:`Series.at` where setting :class:`Timestamp` with timezone raises ``TypeError`` (:issue:`25506`)
215+
- Bug in :func:`DataFrame.update` when updating with timezone aware data would return timezone naive data (:issue:`25807`)
215216

216217
Numeric
217218
^^^^^^^

pandas/core/frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5546,8 +5546,8 @@ def update(self, other, join='left', overwrite=True, filter_func=None,
55465546
other = other.reindex_like(self)
55475547

55485548
for col in self.columns:
5549-
this = self[col].values
5550-
that = other[col].values
5549+
this = self[col]._values
5550+
that = other[col]._values
55515551
if filter_func is not None:
55525552
with np.errstate(all='ignore'):
55535553
mask = ~filter_func(this) | isna(that)

pandas/tests/frame/test_combine_concat.py

+7
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,13 @@ def test_update_from_non_df(self):
357357

358358
assert_frame_equal(df, expected)
359359

360+
def test_update_datetime_tz(self):
361+
# GH 25807
362+
result = DataFrame([pd.Timestamp('2019', tz='UTC')])
363+
result.update(result)
364+
expected = DataFrame([pd.Timestamp('2019', tz='UTC')])
365+
assert_frame_equal(result, expected)
366+
360367
def test_join_str_datetime(self):
361368
str_dates = ['20120209', '20120222']
362369
dt_dates = [datetime(2012, 2, 9), datetime(2012, 2, 22)]

0 commit comments

Comments
 (0)