@@ -237,16 +237,31 @@ def isna(self):
237
237
"""
238
238
raise AbstractMethodError (self )
239
239
240
- def _values_for_argsort (self ):
240
+ def _simple_ndarray (self ):
241
241
# type: () -> ndarray
242
- """Get the ndarray to be passed to np.argsort .
242
+ """Convert the array to a simple ndarray representaiton .
243
243
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.
245
253
246
254
Returns
247
255
-------
248
256
values : ndarray
257
+
258
+ See Also
259
+ --------
260
+ ExtensionArray.argsort
249
261
"""
262
+ # Implemnetor note: This method is currently used in
263
+ # - ExtensionArray.argsort
264
+
250
265
return np .array (self )
251
266
252
267
def argsort (self , ascending = True , kind = 'quicksort' , * args , ** kwargs ):
@@ -274,11 +289,11 @@ def argsort(self, ascending=True, kind='quicksort', *args, **kwargs):
274
289
"""
275
290
# Implementor note: You have two places to override the behavior of
276
291
# argsort.
277
- # 1. _values_for_argsort : construct the values passed to np.argsort
292
+ # 1. _simple_ndarray : construct the values passed to np.argsort
278
293
# 2. argsort : total control over sorting.
279
294
280
295
ascending = nv .validate_argsort_with_ascending (ascending , args , kwargs )
281
- values = self ._values_for_argsort ()
296
+ values = self ._simple_ndarray ()
282
297
result = np .argsort (values , kind = kind , ** kwargs )
283
298
if not ascending :
284
299
result = result [::- 1 ]
0 commit comments