Skip to content

Commit 6673705

Browse files
committed
DOC: doc blurb in basics.rst
1 parent a909e16 commit 6673705

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

doc/source/basics.rst

+15
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,21 @@ Some other sorting notes / nuances:
13111311
compatibility with NumPy methods which expect the ``ndarray.sort``
13121312
behavior.
13131313

1314+
.. versionadded:: 0.14.0
1315+
1316+
``Series`` has the ``nsmallest`` and ``nlargest`` methods which return the
1317+
smallest or largest :math:`n` values. For a large ``Series`` this can be much
1318+
faster than sorting the entire Series and calling ``head(n)`` on the result.
1319+
1320+
.. ipython:: python
1321+
1322+
s = Series(np.random.permutation(10))
1323+
s
1324+
s.order()
1325+
s.nsmallest(3)
1326+
s.nlargest(3)
1327+
1328+
13141329
Sorting by a multi-index column
13151330
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13161331

0 commit comments

Comments
 (0)