Skip to content

Commit a016737

Browse files
committed
docs and tests
1 parent b9392cb commit a016737

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

doc/source/whatsnew/v2.2.1.rst

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Fixed regressions
3737
- Fixed regression in :meth:`DataFrameGroupBy.idxmin`, :meth:`DataFrameGroupBy.idxmax`, :meth:`SeriesGroupBy.idxmin`, :meth:`SeriesGroupBy.idxmax` where values containing the minimum or maximum value for the dtype could produce incorrect results (:issue:`57040`)
3838
- Fixed regression in :meth:`ExtensionArray.to_numpy` raising for non-numeric masked dtypes (:issue:`56991`)
3939
- Fixed regression in :meth:`Index.join` raising ``TypeError`` when joining an empty index to a non-empty index containing mixed dtype values (:issue:`57048`)
40+
- Fixed regression in :meth:`Index.map` that would not change the dtype when the provided mapping would change data from tz-aware to tz-agnostic or tz-agnostic to tz-aware (:issue:`57192`)
4041
- Fixed regression in :meth:`Series.pct_change` raising a ``ValueError`` for an empty :class:`Series` (:issue:`57056`)
4142
- Fixed regression in :meth:`Series.to_numpy` when dtype is given as float and the data contains NaNs (:issue:`57121`)
4243

pandas/tests/indexes/datetimes/methods/test_map.py

+13
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,16 @@ def test_index_map(self, name):
4545
)
4646
exp_index = MultiIndex.from_product(((2018,), range(1, 7)), names=[name, name])
4747
tm.assert_index_equal(index, exp_index)
48+
49+
@pytest.mark.parametrize("input_tz", ["UTC", None])
50+
@pytest.mark.parametrize("output_tz", ["UTC", None])
51+
def test_mapping_tz_to_tz_agnostic(self, input_tz, output_tz):
52+
# GH#57192
53+
index = date_range("2018-01-01", periods=6, freq="ME", tz=input_tz)
54+
expected = date_range("2018-01-01", periods=6, freq="ME", tz=output_tz)
55+
if input_tz == "UTC" and output_tz == "UTC":
56+
method = "tz_convert"
57+
else:
58+
method = "tz_localize"
59+
result = index.map(lambda x: getattr(x, method)(output_tz))
60+
tm.assert_index_equal(result, expected)

0 commit comments

Comments
 (0)