@@ -95,94 +95,42 @@ Backwards incompatible API changes
9595Map on Index types now return other Index types
9696^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9797
98- - ``map`` on an ``Index`` now returns an ``Index``, not an array (:issue:`12766`)
98+ - ``map`` on an ``Index`` now returns an ``Index``, not a numpy array (:issue:`12766`)
9999
100100 .. ipython:: python
101101
102102 idx = Index([1, 2])
103103 idx
104-
105- Previous Behavior:
106-
107- .. code-block:: ipython
108-
109- In [3]: idx.map(lambda x: x * 2)
110- Out[3]: array([2, 4])
111-
112- New Behavior:
113-
114- .. ipython:: python
115-
116- idx.map(lambda x: x * 2)
117-
118- - ``map`` on an ``Index`` or ``MultiIndex`` returns the appropriate type depending on output dimensionality
119-
120- .. ipython:: python
121-
122104 mi = MultiIndex.from_tuples([(1, 2), (2, 4)])
123105 mi
124106
125107 Previous Behavior:
126108
127109 .. code-block:: ipython
128110
129- In [5]: idx.map(lambda x: (x, x * 2))
130- Out[5]: array([(1, 2), (2, 4)], dtype=object)
131-
132-
133- In [6]: mi.map(lambda x: x[0])
134- Out[6]: array([1, 2])
135-
136- New Behavior:
137-
138- .. ipython:: python
139-
140- idx.map(lambda x: (x, x * 2))
141-
142- mi.map(lambda x: x[0])
143-
144-
145- - ``map`` on an ``CategoricalIndex`` now returns a ``CategoricalIndex``, not a Categorical
146-
147- .. ipython:: python
148-
149- ci = CategoricalIndex(list('ABABC'), categories=list('CBA'), ordered=True)
150- ci
111+ In [5]: idx.map(lambda x: x * 2)
112+ Out[5]: array([2, 4])
151113
152- Previous Behavior:
114+ In [6]: idx.map(lambda x: (x, x * 2))
115+ Out[6]: array([(1, 2), (2, 4)], dtype=object)
153116
154- .. code-block:: ipython
117+ In [7]: mi.map(lambda x: x)
118+ Out[7]: array([(1, 2), (2, 4)], dtype=object)
155119
156- In [7]: ci.map(lambda x: x.lower())
157- Out[7]:
158- [a, b, a, b, c]
159- Categories (3, object): [c < b < a]
120+ In [8]: mi.map(lambda x: x[0])
121+ Out[8]: array([1, 2])
160122
161123 New Behavior:
162124
163125 .. ipython:: python
164126
165- ci.map(lambda x: x.lower())
166-
167- - ``map`` on an ``DatetimeIndex`` or ``TimedeltaIndex`` now returns an ``Index`` instance
168-
169- .. ipython:: python
170-
171- dtidx = date_range(start='2016-01-01', end='2016-01-02')
172- dtidx
173-
174- Previous Behavior:
175-
176- .. code-block:: ipython
177-
178- In [8]: dtidx.map(lambda x: x.day)
179- Out[8]: array([1, 2])
127+ idx.map(lambda x: x * 2)
180128
181- New Behavior:
129+ idx.map(lambda x: (x, x * 2))
182130
183- .. ipython:: python
131+ mi.map(lambda x: x)
184132
185- dtidx .map(lambda x: x.day )
133+ mi .map(lambda x: x[0] )
186134
187135
188136- ``map`` on a Series withe datetime64 values may return int64 dtypes rather than int32
0 commit comments