Skip to content

DOC: Clean .ix references in indexing.rst #38080

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 3 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
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
36 changes: 4 additions & 32 deletions doc/source/user_guide/indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -584,48 +584,20 @@ without using a temporary variable.
(bb.groupby(['year', 'team']).sum()
.loc[lambda df: df['r'] > 100])

.. _indexing.deprecate_ix:

IX indexer is deprecated
------------------------

.. warning::

.. versionchanged:: 1.0.0

The ``.ix`` indexer was removed, in favor of the more strict ``.iloc`` and ``.loc`` indexers.
.. _combining_positional_and_label_based_indexing:

``.ix`` offers a lot of magic on the inference of what the user wants to do. To wit, ``.ix`` can decide
to index *positionally* OR via *labels* depending on the data type of the index. This has caused quite a
bit of user confusion over the years.
Combining positional and label-based indexing
---------------------------------------------

The recommended methods of indexing are:

* ``.loc`` if you want to *label* index.
* ``.iloc`` if you want to *positionally* index.
If you wish to get the 0th and the 2nd elements from the index in the 'A' column, you can do:

.. ipython:: python

dfd = pd.DataFrame({'A': [1, 2, 3],
'B': [4, 5, 6]},
index=list('abc'))

dfd

Previous behavior, where you wish to get the 0th and the 2nd elements from the index in the 'A' column.

.. code-block:: ipython

In [3]: dfd.ix[[0, 2], 'A']
Out[3]:
a 1
c 3
Name: A, dtype: int64

Using ``.loc``. Here we will select the appropriate indexes from the index, then use *label* indexing.

.. ipython:: python

dfd.loc[dfd.index[[0, 2]], 'A']

This can also be expressed using ``.iloc``, by explicitly getting locations on the indexers, and using
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.20.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ The recommended methods of indexing are:
- ``.loc`` if you want to *label* index
- ``.iloc`` if you want to *positionally* index.

Using ``.ix`` will now show a ``DeprecationWarning`` with a link to some examples of how to convert code :ref:`here <indexing.deprecate_ix>`.
Using ``.ix`` will now show a ``DeprecationWarning`` with a link to some examples of how to convert code `here <https://pandas.pydata.org/pandas-docs/version/1.0/user_guide/indexing.html#ix-indexer-is-deprecated>`__.


.. ipython:: python
Expand Down