Skip to content

Commit

Permalink
DOC: Clean .ix references in indexing.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
topper-123 committed Nov 26, 2020
1 parent d8a2e74 commit 89604e6
Showing 1 changed file with 4 additions and 36 deletions.
40 changes: 4 additions & 36 deletions doc/source/user_guide/indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -584,45 +584,13 @@ 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.

``.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.

The recommended methods of indexing are:

* ``.loc`` if you want to *label* index.
* ``.iloc`` if you want to *positionally* index.

.. 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
.. _combining_positional_and_label_based_indexing:

In [3]: dfd.ix[[0, 2], 'A']
Out[3]:
a 1
c 3
Name: A, dtype: int64
Combining positional and label-based indexing
---------------------------------------------

Using ``.loc``. Here we will select the appropriate indexes from the index, then use *label* indexing.
If you wish to get the 0th and the 2nd elements from the index in the 'A' column, you can do:

.. ipython:: python
Expand Down

0 comments on commit 89604e6

Please sign in to comment.