Skip to content

Commit 35a8977

Browse files
committed
Change name
1 parent 7bbe796 commit 35a8977

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

pandas/core/arrays/base.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,31 @@ def isna(self):
237237
"""
238238
raise AbstractMethodError(self)
239239

240-
def _values_for_argsort(self):
240+
def _simple_ndarray(self):
241241
# type: () -> ndarray
242-
"""Get the ndarray to be passed to np.argsort.
242+
"""Convert the array to a simple ndarray representaiton.
243243
244-
This is called from within 'ExtensionArray.argsort'.
244+
Many methods can operate indirectly on a cheap-to-compute array that
245+
is somehow representative of the extension array. For example, rather
246+
than sorting an ExtensionArray directly, which might be expensive,
247+
we could convert the ExtensionArray to a representative ndarray of
248+
integers, sort the integers, and perform a ``take``.
249+
250+
The coversion between ExtensionArray and the simple ndarray should be
251+
strictly monotonic https://en.wikipedia.org/wiki/Monotonic_function,
252+
and as cheap to compute as possible.
245253
246254
Returns
247255
-------
248256
values : ndarray
257+
258+
See Also
259+
--------
260+
ExtensionArray.argsort
249261
"""
262+
# Implemnetor note: This method is currently used in
263+
# - ExtensionArray.argsort
264+
250265
return np.array(self)
251266

252267
def argsort(self, ascending=True, kind='quicksort', *args, **kwargs):
@@ -274,11 +289,11 @@ def argsort(self, ascending=True, kind='quicksort', *args, **kwargs):
274289
"""
275290
# Implementor note: You have two places to override the behavior of
276291
# argsort.
277-
# 1. _values_for_argsort : construct the values passed to np.argsort
292+
# 1. _simple_ndarray : construct the values passed to np.argsort
278293
# 2. argsort : total control over sorting.
279294

280295
ascending = nv.validate_argsort_with_ascending(ascending, args, kwargs)
281-
values = self._values_for_argsort()
296+
values = self._simple_ndarray()
282297
result = np.argsort(values, kind=kind, **kwargs)
283298
if not ascending:
284299
result = result[::-1]

pandas/core/arrays/categorical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ def check_for_ordered(self, op):
13901390
"you can use .as_ordered() to change the "
13911391
"Categorical to an ordered one\n".format(op=op))
13921392

1393-
def _values_for_argsort(self):
1393+
def _simple_ndarray(self):
13941394
return self._codes.copy()
13951395

13961396
def argsort(self, *args, **kwargs):

0 commit comments

Comments
 (0)