Skip to content

Commit 6eb2e5a

Browse files
authored
Update v0.24.0.txt
1 parent abeda10 commit 6eb2e5a

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

doc/source/whatsnew/v0.24.0.txt

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,37 @@ is the case with :attr:`Period.end_time`, for example
368368

369369
p.end_time
370370

371+
.. _whatsnew_0240.api_breaking.frame_to_dict_index_orient:
372+
373+
Raise ValueError in ``DataFrame.to_dict(orient='index')``
374+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
375+
376+
Bug in :func:`DataFrame.to_dict` raises ``ValueError`` when used with
377+
``orient='index'`` and a non-unique index instead of losing data (:issue:`22801`)
378+
379+
Previous Behavior:
380+
381+
Calling :func:`DataFrame.to_dict` resulted in data loss when ``orient='index'``
382+
for non-unique indexes
383+
384+
.. code-block:: ipython
385+
386+
In [2]: df = pd.DataFrame({'a': [1, 2], 'b': [0.5, 0.75]}, index=['A', 'A'])
387+
388+
In [3]: df.to_dict(orient='index')
389+
Out [3]: {'A': {'a': 2.0, 'b': 0.75}}
390+
391+
Current Behavior:
392+
393+
Calling :func:`DataFrame.to_dict` will now result in a ValueError being raised
394+
when ``orient='index'`` for non-unique index values
395+
396+
.. ipython:: python
397+
398+
df = pd.DataFrame({'a': [1, 2], 'b': [0.5, 0.75]}, index=['A', 'A'])
399+
400+
df.to_dict(orient='index')
401+
371402
.. _whatsnew_0240.api.datetimelike.normalize:
372403

373404
Tick DateOffset Normalize Restrictions
@@ -804,7 +835,7 @@ Reshaping
804835
- Bug in :meth:`Series.replace` and meth:`DataFrame.replace` when dict is used as the ``to_replace`` value and one key in the dict is is another key's value, the results were inconsistent between using integer key and using string key (:issue:`20656`)
805836
- Bug in :meth:`DataFrame.drop_duplicates` for empty ``DataFrame`` which incorrectly raises an error (:issue:`20516`)
806837
- Bug in :func:`pandas.wide_to_long` when a string is passed to the stubnames argument and a column name is a substring of that stubname (:issue:`22468`)
807-
- Bug in :func:`DataFrame.to_dict` raises ``ValueError`` when used with ``orient='index'`` and a non-unique index instead of losing data (:issue:`22801`)
838+
-
808839

809840
Build Changes
810841
^^^^^^^^^^^^^

0 commit comments

Comments
 (0)