Skip to content

Commit ca3bf42

Browse files
committed
Whatsnew section
1 parent cd54349 commit ca3bf42

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

doc/source/whatsnew/v0.23.0.txt

+31
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,37 @@ Please note that the string `index` is not supported with the round trip format,
176176
new_df
177177
print(new_df.index.name)
178178

179+
.. _whatsnew_0230.enhancements.index_division_by_zero
180+
181+
Index Division By Zero Fills Correctly
182+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
183+
184+
Division operations on ``Index`` and subclasses will now fill positive / 0 with ``np.inf``, negative / 0 with ``-np.inf``, and 0 / 0 with ``np.nan``. This matches existing Series behavior.
185+
186+
Current Behavior:
187+
188+
.. code-block:: ipython
189+
190+
In [3]: index = pd.Index([-1, 0, 1])
191+
In [4]: index / 0
192+
Out[4]: Int64Index([0, 0, 0], dtype='int64')
193+
In [5]: index / 0.0
194+
Out[5]: Float64Index([-inf, nan, inf], dtype='float64')
195+
196+
In [6]: index = pd.UInt64Index([0, 1])
197+
In [7]: index / np.array([0, 0], dtype=np.uint64)
198+
Out[7]: UInt64Index([0, 0], dtype='uint64')
199+
200+
Previous Behavior:
201+
202+
.. code-block:: ipython
203+
204+
index = pd.Index([-1, 0, 1])
205+
index / 0
206+
207+
index = pd.UInt64Index([0, 1])
208+
index / np.array([0, 0], dtype=np.uint64)
209+
179210
.. _whatsnew_0230.enhancements.other:
180211

181212
Other Enhancements

0 commit comments

Comments
 (0)