Skip to content

Commit 378abb9

Browse files
author
tp
committed
add test to test_nanops.py + doc cleanup
1 parent a7a7f8c commit 378abb9

File tree

3 files changed

+41
-37
lines changed

3 files changed

+41
-37
lines changed

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ Here are just a few of the things that pandas does well:
106106
- Make it [**easy to convert**][conversion] ragged,
107107
differently-indexed data in other Python and NumPy data structures
108108
into DataFrame objects
109-
- Intelligent label-based [**slicing**][slicing], [**fancy
110-
indexing**][fancy-indexing], and [**subsetting**][subsetting] of
111-
large data sets
109+
- Intelligent label-based [**slicing**][slicing], [**selecting**][selecting],
110+
and [**subsetting**][subsetting] of large data sets
112111
- Intuitive [**merging**][merging] and [**joining**][joining] data
113112
sets
114113
- Flexible [**reshaping**][reshape] and [**pivoting**][pivot-table] of
@@ -129,7 +128,7 @@ Here are just a few of the things that pandas does well:
129128
[groupby]: https://pandas.pydata.org/pandas-docs/stable/groupby.html#group-by-split-apply-combine
130129
[conversion]: https://pandas.pydata.org/pandas-docs/stable/dsintro.html#dataframe
131130
[slicing]: https://pandas.pydata.org/pandas-docs/stable/indexing.html#slicing-ranges
132-
[fancy-indexing]: https://pandas.pydata.org/pandas-docs/stable/indexing.html#advanced-indexing-with-ix
131+
[selecting]: https://pandas.pydata.org/pandas-docs/stable/indexing.html#selection-by-label
133132
[subsetting]: https://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing
134133
[merging]: https://pandas.pydata.org/pandas-docs/stable/merging.html#database-style-dataframe-joining-merging
135134
[joining]: https://pandas.pydata.org/pandas-docs/stable/merging.html#joining-on-index

doc/source/indexing.rst

+33-32
Original file line numberDiff line numberDiff line change
@@ -304,38 +304,6 @@ largely as a convenience since it is such a common operation.
304304
Selection By Label
305305
------------------
306306

307-
.. warning::
308-
309-
Whether a copy or a reference is returned for a setting operation, may depend on the context.
310-
This is sometimes called ``chained assignment`` and should be avoided.
311-
See :ref:`Returning a View versus Copy <indexing.view_versus_copy>`.
312-
313-
.. warning::
314-
315-
``.loc`` is strict when you present slicers that are not compatible (or convertible) with the index type. For example
316-
using integers in a ``DatetimeIndex``. These will raise a ``TypeError``.
317-
318-
.. ipython:: python
319-
320-
dfl = pd.DataFrame(np.random.randn(5,4), columns=list('ABCD'), index=pd.date_range('20130101',periods=5))
321-
dfl
322-
323-
.. code-block:: ipython
324-
325-
In [4]: dfl.loc[2:3]
326-
TypeError: cannot do slice indexing on <class 'pandas.tseries.index.DatetimeIndex'> with these indexers [2] of <type 'int'>
327-
328-
String likes in slicing *can* be convertible to the type of the index and lead to natural slicing.
329-
330-
.. ipython:: python
331-
332-
dfl.loc['20130102':'20130104']
333-
334-
.. warning::
335-
336-
Starting in 0.21.0, pandas will show a ``FutureWarning`` if indexing with a list with missing labels. In the future
337-
this will raise a ``KeyError``. See :ref:`list-like Using loc with missing keys in a list is Deprecated <indexing.deprecate_loc_reindex_listlike>`.
338-
339307
pandas provides a suite of methods in order to have **purely label based indexing**. This is a strict inclusion based protocol.
340308
Every label asked for must be in the index, or a ``KeyError`` will be raised.
341309
When slicing, both the start bound **AND** the stop bound are *included*, if present in the index.
@@ -352,6 +320,12 @@ The ``.loc`` attribute is the primary access method. The following are valid inp
352320
- A boolean array.
353321
- A ``callable``, see :ref:`Selection By Callable <indexing.callable>`.
354322

323+
.. warning::
324+
325+
Whether a copy or a reference is returned for a setting operation, may depend on the context.
326+
This is sometimes called ``chained assignment`` and should be avoided.
327+
See :ref:`Returning a View versus Copy <indexing.view_versus_copy>`.
328+
355329
.. ipython:: python
356330
357331
s1 = pd.Series(np.random.randn(6),index=list('abcdef'))
@@ -402,6 +376,33 @@ For getting a value explicitly (equivalent to deprecated ``df.get_value('a','A')
402376
# this is also equivalent to ``df1.at['a','A']``
403377
df1.loc['a', 'A']
404378
379+
.. warning::
380+
381+
``.loc`` is strict when you present slicers that are not compatible (or convertible) with the index type. For example
382+
using integers in a ``DatetimeIndex``. These will raise a ``TypeError``.
383+
384+
.. ipython:: python
385+
386+
dfl = pd.DataFrame(np.random.randn(5,4), columns=list('ABCD'),
387+
index=pd.date_range('20130101',periods=5))
388+
dfl
389+
390+
.. code-block:: ipython
391+
392+
In [4]: dfl.loc[2:3]
393+
TypeError: cannot do slice indexing on <class 'pandas.tseries.index.DatetimeIndex'> with these indexers [2] of <type 'int'>
394+
395+
String likes in slicing *can* be convertible to the type of the index and lead to natural slicing.
396+
397+
.. ipython:: python
398+
399+
dfl.loc['20130102':'20130104']
400+
401+
.. warning::
402+
403+
Starting in 0.21.0, pandas will show a ``FutureWarning`` if indexing with a list with missing labels. In the future
404+
this will raise a ``KeyError``. See :ref:`list-like Using loc with missing keys in a list is Deprecated <indexing.deprecate_loc_reindex_listlike>`.
405+
405406
.. _indexing.slicing_with_labels:
406407

407408
Slicing with labels

pandas/tests/test_nanops.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import pandas.core.nanops as nanops
1414
import pandas.util.testing as tm
1515
import pandas.util._test_decorators as td
16-
from pandas.compat.numpy import _np_version_under1p13
16+
from pandas.compat.numpy import _np_version_under1p13, _np_version_under1p10
1717

1818
use_bn = nanops._USE_BOTTLENECK
1919

@@ -1023,6 +1023,10 @@ def test_use_bottleneck():
10231023
(np.nansum, 10),
10241024
(np.mean, 2.5),
10251025
(np.nanmean, 2.5),
1026+
(np.prod, 24),
1027+
pytest.param(getattr(np, 'nanprod', None), 24,
1028+
marks=pytest.mark.skipif(_np_version_under1p10,
1029+
reason="numpy >=1.10 required")),
10261030
(np.median, 2.5),
10271031
(np.nanmedian, 2.5),
10281032
(np.min, 1),

0 commit comments

Comments
 (0)