Skip to content

Commit be9ec10

Browse files
committed
amend after review
1 parent 51a9d4a commit be9ec10

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

doc/source/whatsnew/v0.25.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Other API Changes
252252
- The ``arg`` argument in :meth:`pandas.core.groupby.DataFrameGroupBy.agg` has been renamed to ``func`` (:issue:`26089`)
253253
- The ``arg`` argument in :meth:`pandas.core.window._Window.aggregate` has been renamed to ``func`` (:issue:`26372`)
254254
- Most Pandas classes had a ``__bytes__`` method, which was used for getting a python2-style bytestring representation of the object. This method has been removed as a part of dropping Python2 (:issue:`26447`)
255-
- :meth:`ExtensionArray.argsort` places the nan at the end of the sorted array (:issue:`21801`)
255+
- :meth:`ExtensionArray.argsort` places the ``nan`` at the end of the sorted array (:issue:`21801`)
256256

257257
.. _whatsnew_0250.deprecations:
258258

pandas/core/arrays/base.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ def _values_for_argsort(self) -> Tuple[np.ndarray, np.ndarray]:
373373
ndarray
374374
The mask which indicates the NA values.
375375
376+
.. versionadded:: 0.25.0
377+
376378
See Also
377379
--------
378380
ExtensionArray.argsort
@@ -410,17 +412,15 @@ def argsort(self, ascending=True, kind='quicksort', *args, **kwargs):
410412
ascending = nv.validate_argsort_with_ascending(ascending, args, kwargs)
411413
values, mask = self._values_for_argsort()
412414

413-
def permutation(mask):
414-
# Return a permutation which maps the indices of the
415-
# subarray without nan to the indices of the original array.
416-
permu = np.arange(len(mask))
417-
permu = permu[~mask]
418-
return permu
419-
420415
if mask.any():
421416
notmask = ~mask
422417
notnull = np.argsort(values[notmask], kind=kind, **kwargs)
423-
permu = permutation(mask)
418+
419+
# permu maps the indices of the subarray
420+
# without nan to the indices of the original array.
421+
permu = np.arange(len(mask))
422+
permu = permu[~mask]
423+
424424
notnull = permu[notnull]
425425
allnan = np.arange(len(self))[mask]
426426
result = np.append(notnull, allnan)

pandas/core/arrays/integer.py

+2
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ def _values_for_argsort(self) -> Tuple[np.ndarray, np.ndarray]:
523523
ndarray
524524
The mask which indicates the NA values.
525525
526+
.. versionadded:: 0.25.0
527+
526528
See Also
527529
--------
528530
ExtensionArray.argsort

0 commit comments

Comments
 (0)