You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/indexing.rst
+7-18
Original file line number
Diff line number
Diff line change
@@ -104,24 +104,13 @@ of multi-axis indexing.
104
104
105
105
See more at :ref:`Selection by Position <indexing.integer>`
106
106
107
-
- ``.ix`` supports mixed integer and label based access. It is primarily label
108
-
based, but will fall back to integer positional access unless the corresponding
109
-
axis is of integer type. ``.ix`` is the most general and will
110
-
support any of the inputs in ``.loc`` and ``.iloc``. ``.ix`` also supports floating point
111
-
label schemes. ``.ix`` is exceptionally useful when dealing with mixed positional
112
-
and label based hierarchical indexes.
113
-
114
-
However, when an axis is integer based, ONLY
115
-
label based access and not positional access is supported.
116
-
Thus, in such cases, it's usually better to be explicit and use ``.iloc`` or ``.loc``.
117
-
118
107
See more at :ref:`Advanced Indexing <advanced>` and :ref:`Advanced
119
108
Hierarchical <advanced.advanced_hierarchical>`.
120
109
121
-
- ``.loc``, ``.iloc``, ``.ix`` and also ``[]`` indexing can accept a ``callable`` as indexer. See more at :ref:`Selection By Callable <indexing.callable>`.
110
+
- ``.loc``, ``.iloc``, and also ``[]`` indexing can accept a ``callable`` as indexer. See more at :ref:`Selection By Callable <indexing.callable>`.
122
111
123
112
Getting values from an object with multi-axes selection uses the following
124
-
notation (using ``.loc`` as an example, but applies to ``.iloc`` and ``.ix`` as
113
+
notation (using ``.loc`` as an example, but applies to ``.iloc`` as
125
114
well). Any of the axes accessors may be the null slice ``:``. Axes left out of
126
115
the specification are assumed to be ``:``. (e.g. ``p.loc['a']`` is equiv to
127
116
``p.loc['a', :, :]``)
@@ -193,7 +182,7 @@ columns.
193
182
194
183
.. warning::
195
184
196
-
pandas aligns all AXES when setting ``Series`` and ``DataFrame`` from ``.loc``, ``.iloc`` and ``.ix``.
185
+
pandas aligns all AXES when setting ``Series`` and ``DataFrame`` from ``.loc``, and ``.iloc``.
197
186
198
187
This will **not** modify ``df`` because the column alignment is before value assignment.
199
188
@@ -526,7 +515,7 @@ Selection By Callable
526
515
527
516
.. versionadded:: 0.18.1
528
517
529
-
``.loc``, ``.iloc``, ``.ix`` and also ``[]`` indexing can accept a ``callable`` as indexer.
518
+
``.loc``, ``.iloc``, and also ``[]`` indexing can accept a ``callable`` as indexer.
530
519
The ``callable`` must be a function with one argument (the calling Series, DataFrame or Panel) and that returns valid output for indexing.
531
520
532
521
.. ipython:: python
@@ -641,7 +630,7 @@ Setting With Enlargement
641
630
642
631
.. versionadded:: 0.13
643
632
644
-
The ``.loc/.ix/[]`` operations can perform enlargement when setting a non-existant key for that axis.
633
+
The ``.loc/[]`` operations can perform enlargement when setting a non-existant key for that axis.
645
634
646
635
In the ``Series`` case this is effectively an appending operation
647
636
@@ -906,7 +895,7 @@ without creating a copy:
906
895
907
896
Furthermore, ``where`` aligns the input boolean condition (ndarray or DataFrame),
908
897
such that partial selection with setting is possible. This is analogous to
909
-
partial setting via ``.ix`` (but on the contents rather than the axis labels)
898
+
partial setting via ``.loc`` (but on the contents rather than the axis labels)
910
899
911
900
.. ipython:: python
912
901
@@ -1716,7 +1705,7 @@ A chained assignment can also crop up in setting in a mixed dtype frame.
1716
1705
1717
1706
.. note::
1718
1707
1719
-
These setting rules apply to all of ``.loc/.iloc/.ix``
1708
+
These setting rules apply to all of ``.loc/.iloc``
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v0.20.0.txt
+48
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ users upgrade to this version.
10
10
Highlights include:
11
11
12
12
- Building pandas for development now requires ``cython >= 0.23`` (:issue:`14831`)
13
+
- The ``.ix`` indexer has been deprecated, see :ref:`here <whatsnew.api_breaking.deprecate_ix>`
13
14
14
15
Check the :ref:`API Changes <whatsnew_0200.api_breaking>` and :ref:`deprecations <whatsnew_0200.deprecations>` before updating.
15
16
@@ -122,6 +123,53 @@ Other enhancements
122
123
Backwards incompatible API changes
123
124
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124
125
126
+
127
+
.. _whatsnew.api_breaking.deprecate_ix
128
+
129
+
Deprecate .ix
130
+
^^^^^^^^^^^^^
131
+
132
+
The ``.ix`` indexer is deprecated, in favor of the more ``.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*. This has caused quite a bit of user confusion over the years. The full indexing documentation are :ref:`here <indexing>`. (:issue:`14218`)
133
+
134
+
135
+
The recommended methods of indexing are:
136
+
137
+
- ``.loc`` if you want to *label* index
138
+
- ``.iloc`` if you want to *positionally* index.
139
+
140
+
Using ``.ix`` will now show a deprecation warning with a mini-example of how to convert code.
141
+
142
+
.. ipython:: python
143
+
144
+
df = pd.DataFrame({'A': [1, 2, 3],
145
+
'B': [4, 5, 6]},
146
+
index=list('abc'))
147
+
148
+
df
149
+
150
+
Previous Behavior, where you wish to get the 0th and the 2nd elements from the index in the 'A' column.
151
+
152
+
.. code-block:: ipython
153
+
154
+
In [3]: df.ix[[0, 2], 'A']
155
+
Out[3]:
156
+
a 1
157
+
c 3
158
+
Name: A, dtype: int64
159
+
160
+
Using ``.loc``. Here we will select the appropriate indexes from the index, then use *label* indexing.
161
+
162
+
.. ipython:: python
163
+
164
+
df.loc[df.index[[0, 2]], 'A']
165
+
166
+
Using ``.iloc``. Here we will get the location of the 'A' column, then use *positional* indexing to select things.
0 commit comments