Skip to content

Commit 48655b5

Browse files
committed
Update whatsnew and add git PR to tests to denote changes
1 parent 9a28a29 commit 48655b5

File tree

2 files changed

+103
-1
lines changed

2 files changed

+103
-1
lines changed

doc/source/whatsnew/v0.20.0.txt

+101-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Highlights include:
1212

1313
Check the :ref:`API Changes <whatsnew_0200.api_breaking>` and :ref:`deprecations <whatsnew_0200.deprecations>` before updating.
1414

15-
.. contents:: What's new in v0.19.0
15+
.. contents:: What's new in v0.20.0
1616
:local:
1717
:backlinks: none
1818

@@ -38,6 +38,10 @@ Other enhancements
3838
Backwards incompatible API changes
3939
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4040

41+
42+
Map on Index types now return other Index types
43+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44+
4145
- ``map`` on an ``Index`` now returns an ``Index``, not an array (:issue:`12766`)
4246

4347
.. ipython:: python
@@ -58,6 +62,102 @@ Backwards incompatible API changes
5862

5963
idx.map(lambda x: x * 2)
6064

65+
- ``map`` on an ``Index`` or ``MultiIndex`` returns the appropriate type depending on output dimensionality
66+
67+
.. ipython:: python
68+
69+
mi = MultiIndex.from_tuples([(1, 2), (2, 4)])
70+
mi
71+
72+
Previous Behavior:
73+
74+
.. code-block:: ipython
75+
76+
In [5]: idx.map(lambda x: (x, x * 2))
77+
Out[5]: array([(1, 2), (2, 4)], dtype=object)
78+
79+
80+
In [6]: mi.map(lambda x: x[0])
81+
Out[6]: array([1, 2])
82+
83+
New Behavior:
84+
85+
.. ipython:: python
86+
87+
idx.map(lambda x: (x, x * 2))
88+
89+
mi.map(lambda x: x[0])
90+
91+
92+
- ``map`` on an ``CategoricalIndex`` now returns a ``CategoricalIndex``, not a Categorical
93+
94+
.. ipython:: python
95+
96+
ci = CategoricalIndex(list('ABABC'), categories=list('CBA'), ordered=True)
97+
ci
98+
99+
Previous Behavior:
100+
101+
.. code-block:: ipython
102+
103+
In [7]: ci.map(lambda x: x.lower())
104+
Out[7]:
105+
[a, b, a, b, c]
106+
Categories (3, object): [c < b < a]
107+
108+
New Behavior:
109+
110+
.. ipython:: python
111+
112+
ci.map(lambda x: x.lower())
113+
114+
- ``map`` on an ``DatetimeIndex`` or ``TimedeltaIndex`` now returns an ``Index`` instance
115+
116+
.. ipython:: python
117+
118+
dtidx = date_range(start='2016-01-01', end='2016-01-02')
119+
dtidx
120+
121+
Previous Behavior:
122+
123+
.. code-block:: ipython
124+
125+
In [8]: dtidx.map(lambda x: x.day)
126+
Out[8]: array([1, 2])
127+
128+
New Behavior:
129+
130+
.. ipython:: python
131+
132+
dtidx.map(lambda x: x.day)
133+
134+
135+
- ``map`` on a Series withe datetime64 values may return int64 dtypes rather than int32
136+
137+
.. ipython:: python
138+
139+
s = Series(date_range('2011-01-02T00:00', '2011-01-02T02:00', freq='H').tz_localize('Asia/Tokyo'))
140+
s
141+
142+
Previous Behavior:
143+
144+
.. code-block:: ipython
145+
146+
In [9]: s.map(lambda x: x.hour)
147+
Out[9]:
148+
0 0
149+
1 1
150+
2 2
151+
dtype: int32
152+
153+
154+
New Behavior:
155+
156+
.. ipython:: python
157+
158+
s.map(lambda x: x.hour)
159+
160+
61161
.. _whatsnew_0200.api:
62162

63163

pandas/tests/series/test_apply.py

+2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def test_apply_datetimetz(self):
123123
tm.assert_series_equal(result, exp)
124124

125125
# change dtype
126+
# GH 14506 : Returned dtype changed from int32 to int64
126127
result = s.apply(lambda x: x.hour)
127128
exp = pd.Series(list(range(24)) + [0], name='XX', dtype=np.int64)
128129
tm.assert_series_equal(result, exp)
@@ -317,6 +318,7 @@ def test_map_datetimetz(self):
317318
tm.assert_series_equal(result, exp)
318319

319320
# change dtype
321+
# GH 14506 : Returned dtype changed from int32 to int64
320322
result = s.map(lambda x: x.hour)
321323
exp = pd.Series(list(range(24)) + [0], name='XX', dtype=np.int64)
322324
tm.assert_series_equal(result, exp)

0 commit comments

Comments
 (0)