Skip to content

DOC: Add mention that mangle_dupe_cols is deprecated in user guide #48182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 9 additions & 21 deletions doc/source/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ mangle_dupe_cols : boolean, default ``True``
Passing in ``False`` will cause data to be overwritten if there are duplicate
names in the columns.

.. deprecated:: 1.5.0
The argument was never implemented, and a new argument where the
renaming pattern can be specified will be added instead.

General parsing configuration
+++++++++++++++++++++++++++++

Expand Down Expand Up @@ -611,6 +615,10 @@ If the header is in a row other than the first, pass the row number to
Duplicate names parsing
'''''''''''''''''''''''

.. deprecated:: 1.5.0
``mangle_dupe_cols`` was never implemented, and a new argument where the
renaming pattern can be specified will be added instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd personally update the section to just show that we rename columns, and remove all the references to mangle_dupe_cols, which never worked anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me. Removed the example with False

If the file or header contains duplicate names, pandas will by default
distinguish between them so as to prevent overwriting data:

Expand All @@ -621,27 +629,7 @@ distinguish between them so as to prevent overwriting data:

There is no more duplicate data because ``mangle_dupe_cols=True`` by default,
which modifies a series of duplicate columns 'X', ..., 'X' to become
'X', 'X.1', ..., 'X.N'. If ``mangle_dupe_cols=False``, duplicate data can
arise:

.. code-block:: ipython

In [2]: data = 'a,b,a\n0,1,2\n3,4,5'
In [3]: pd.read_csv(StringIO(data), mangle_dupe_cols=False)
Out[3]:
a b a
0 2 1 2
1 5 4 5

To prevent users from encountering this problem with duplicate data, a ``ValueError``
exception is raised if ``mangle_dupe_cols != True``:

.. code-block:: ipython

In [2]: data = 'a,b,a\n0,1,2\n3,4,5'
In [3]: pd.read_csv(StringIO(data), mangle_dupe_cols=False)
...
ValueError: Setting mangle_dupe_cols=False is not supported yet
'X', 'X.1', ..., 'X.N'.

.. _io.usecols:

Expand Down