@@ -187,36 +187,29 @@ Previous Behavior:
187
187
188
188
.. code-block:: ipython
189
189
190
- In [6]: index = pd.Index ([-1, 0, 1])
190
+ In [6]: index = pd.Int64Index ([-1, 0, 1])
191
191
192
192
In [7]: index / 0
193
193
Out[7]: Int64Index([0, 0, 0], dtype='int64')
194
194
195
- In [8]: index = pd.UInt64Index([0, 1])
195
+ # Previous behavior yielded different results depending on the type of zero in the divisor
196
+ In [8]: index / 0.0
197
+ Out[8]: Float64Index([-inf, nan, inf], dtype='float64')
196
198
197
- In [9]: index / np.array([0, 0], dtype=np.uint64)
198
- Out[9]: UInt64Index([0, 0], dtype='uint64')
199
+ In [9]: index = pd.UInt64Index([0, 1])
199
200
200
- In [10]: pd.RangeIndex(1, 5) / 0
201
- ---------------------------------------------------------------------------
202
- ZeroDivisionError Traceback (most recent call last)
203
- <ipython-input-10-4c5e91d516f3> in <module>()
204
- ----> 1 pd.RangeIndex(1, 5) / 0
205
-
206
- /usr/local/lib/python2.7/site-packages/pandas/core/indexes/range.pyc in _evaluate_numeric_binop(self, other)
207
- 592 if step:
208
- 593 with np.errstate(all='ignore'):
209
- --> 594 rstep = step(self._step, other)
210
- 595
211
- 596 # we don't have a representable op
201
+ In [10]: index / np.array([0, 0], dtype=np.uint64)
202
+ Out[10]: UInt64Index([0, 0], dtype='uint64')
212
203
204
+ In [11]: pd.RangeIndex(1, 5) / 0
213
205
ZeroDivisionError: integer division or modulo by zero
214
206
215
207
Current Behavior:
216
208
217
209
.. ipython:: python
218
210
219
- index = pd.Index([-1, 0, 1])
211
+ index = pd.Int64Index([-1, 0, 1])
212
+ # division by zero gives -infinity where negative, +infinity where positive, and NaN for 0 / 0
220
213
index / 0
221
214
222
215
# The result of division by zero should not depend on whether the zero is int or float
0 commit comments