@@ -95,94 +95,42 @@ Backwards incompatible API changes
95
95
Map on Index types now return other Index types
96
96
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
97
97
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`)
99
99
100
100
.. ipython:: python
101
101
102
102
idx = Index([1, 2])
103
103
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
-
122
104
mi = MultiIndex.from_tuples([(1, 2), (2, 4)])
123
105
mi
124
106
125
107
Previous Behavior:
126
108
127
109
.. code-block:: ipython
128
110
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])
151
113
152
- Previous Behavior:
114
+ In [6]: idx.map(lambda x: (x, x * 2))
115
+ Out[6]: array([(1, 2), (2, 4)], dtype=object)
153
116
154
- .. code-block:: ipython
117
+ In [7]: mi.map(lambda x: x)
118
+ Out[7]: array([(1, 2), (2, 4)], dtype=object)
155
119
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])
160
122
161
123
New Behavior:
162
124
163
125
.. ipython:: python
164
126
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)
180
128
181
- New Behavior:
129
+ idx.map(lambda x: (x, x * 2))
182
130
183
- .. ipython:: python
131
+ mi.map(lambda x: x)
184
132
185
- dtidx .map(lambda x: x.day )
133
+ mi .map(lambda x: x[0] )
186
134
187
135
188
136
- ``map`` on a Series withe datetime64 values may return int64 dtypes rather than int32
0 commit comments