diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 2ed2c21ba5584..7e9296b0e728b 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -211,6 +211,7 @@ Timezones - Bug in :func:`to_datetime` with ``utc=True`` and datetime strings that would apply previously parsed UTC offsets to subsequent arguments (:issue:`24992`) - Bug in :func:`Timestamp.tz_localize` and :func:`Timestamp.tz_convert` does not propagate ``freq`` (:issue:`25241`) - Bug in :func:`Series.at` where setting :class:`Timestamp` with timezone raises ``TypeError`` (:issue:`25506`) +- Bug in :func:`DataFrame.update` when updating with timezone aware data would return timezone naive data (:issue:`25807`) Numeric ^^^^^^^ diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 75f2ac8cbb7e7..ec881c730c365 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -5546,8 +5546,8 @@ def update(self, other, join='left', overwrite=True, filter_func=None, other = other.reindex_like(self) for col in self.columns: - this = self[col].values - that = other[col].values + this = self[col]._values + that = other[col]._values if filter_func is not None: with np.errstate(all='ignore'): mask = ~filter_func(this) | isna(that) diff --git a/pandas/tests/frame/test_combine_concat.py b/pandas/tests/frame/test_combine_concat.py index c803d15a690c4..f905a0eb046ee 100644 --- a/pandas/tests/frame/test_combine_concat.py +++ b/pandas/tests/frame/test_combine_concat.py @@ -357,6 +357,13 @@ def test_update_from_non_df(self): assert_frame_equal(df, expected) + def test_update_datetime_tz(self): + # GH 25807 + result = DataFrame([pd.Timestamp('2019', tz='UTC')]) + result.update(result) + expected = DataFrame([pd.Timestamp('2019', tz='UTC')]) + assert_frame_equal(result, expected) + def test_join_str_datetime(self): str_dates = ['20120209', '20120222'] dt_dates = [datetime(2012, 2, 9), datetime(2012, 2, 22)]