Skip to content

DOC: Some doc cleanup #19968

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

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ Here are just a few of the things that pandas does well:
- Make it [**easy to convert**][conversion] ragged,
differently-indexed data in other Python and NumPy data structures
into DataFrame objects
- Intelligent label-based [**slicing**][slicing], [**fancy
indexing**][fancy-indexing], and [**subsetting**][subsetting] of
large data sets
- Intelligent label-based [**slicing**][slicing], [**selecting**][selecting],
and [**subsetting**][subsetting] of large data sets
- Intuitive [**merging**][merging] and [**joining**][joining] data
sets
- Flexible [**reshaping**][reshape] and [**pivoting**][pivot-table] of
Expand All @@ -129,7 +128,7 @@ Here are just a few of the things that pandas does well:
[groupby]: https://pandas.pydata.org/pandas-docs/stable/groupby.html#group-by-split-apply-combine
[conversion]: https://pandas.pydata.org/pandas-docs/stable/dsintro.html#dataframe
[slicing]: https://pandas.pydata.org/pandas-docs/stable/indexing.html#slicing-ranges
[fancy-indexing]: https://pandas.pydata.org/pandas-docs/stable/indexing.html#advanced-indexing-with-ix
[selecting]: https://pandas.pydata.org/pandas-docs/stable/indexing.html#selection-by-label
[subsetting]: https://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing
[merging]: https://pandas.pydata.org/pandas-docs/stable/merging.html#database-style-dataframe-joining-merging
[joining]: https://pandas.pydata.org/pandas-docs/stable/merging.html#joining-on-index
Expand Down
44 changes: 23 additions & 21 deletions doc/source/indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -310,27 +310,6 @@ Selection By Label
This is sometimes called ``chained assignment`` and should be avoided.
See :ref:`Returning a View versus Copy <indexing.view_versus_copy>`.

.. warning::

``.loc`` is strict when you present slicers that are not compatible (or convertible) with the index type. For example
using integers in a ``DatetimeIndex``. These will raise a ``TypeError``.

.. ipython:: python

dfl = pd.DataFrame(np.random.randn(5,4), columns=list('ABCD'), index=pd.date_range('20130101',periods=5))
dfl

.. code-block:: ipython

In [4]: dfl.loc[2:3]
TypeError: cannot do slice indexing on <class 'pandas.tseries.index.DatetimeIndex'> with these indexers [2] of <type 'int'>

String likes in slicing *can* be convertible to the type of the index and lead to natural slicing.

.. ipython:: python

dfl.loc['20130102':'20130104']

.. warning::

Starting in 0.21.0, pandas will show a ``FutureWarning`` if indexing with a list with missing labels. In the future
Expand Down Expand Up @@ -430,6 +409,29 @@ error will be raised (since doing otherwise would be computationally expensive,
as well as potentially ambiguous for mixed type indexes). For instance, in the
above example, ``s.loc[1:6]`` would raise ``KeyError``.

.. warning::

``.loc`` is strict when you present slicers that are not compatible
(or convertible) with the index type. For example using integers in a
``DatetimeIndex``. These will raise a ``TypeError``.

.. ipython:: python

dfl = pd.DataFrame(np.random.randn(5,4), columns=list('ABCD'),
index=pd.date_range('20130101',periods=5))
dfl

.. code-block:: ipython

In [4]: dfl.loc[2:3]
TypeError: cannot do slice indexing on <class 'pandas.tseries.index.DatetimeIndex'> with these indexers [2] of <type 'int'>

String likes in slicing *can* be convertible to the type of the index and lead to natural slicing.

.. ipython:: python

dfl.loc['20130102':'20130104']

.. _indexing.integer:

Selection By Position
Expand Down