@@ -294,25 +294,6 @@ def _get_hashtable_algo(values: np.ndarray):
294
294
return htable , values
295
295
296
296
297
- def _get_values_for_rank (values : ArrayLike ) -> np .ndarray :
298
-
299
- values = _ensure_data (values )
300
- if values .dtype .kind in ["i" , "u" , "f" ]:
301
- # rank_t includes only object, int64, uint64, float64
302
- dtype = values .dtype .kind + "8"
303
- values = values .astype (dtype , copy = False )
304
- return values
305
-
306
-
307
- def _get_data_algo (values : ArrayLike ):
308
- values = _get_values_for_rank (values )
309
-
310
- ndtype = _check_object_for_strings (values )
311
- htable = _hashtables .get (ndtype , _hashtables ["object" ])
312
-
313
- return htable , values
314
-
315
-
316
297
def _check_object_for_strings (values : np .ndarray ) -> str :
317
298
"""
318
299
Check if we can use string hashtable instead of object hashtable.
@@ -562,7 +543,7 @@ def factorize_array(
562
543
codes : ndarray[np.intp]
563
544
uniques : ndarray
564
545
"""
565
- hash_klass , values = _get_data_algo (values )
546
+ hash_klass , values = _get_hashtable_algo (values )
566
547
567
548
table = hash_klass (size_hint or len (values ))
568
549
uniques , codes = table .factorize (
@@ -1020,7 +1001,13 @@ def rank(
1020
1001
(e.g. 1, 2, 3) or in percentile form (e.g. 0.333..., 0.666..., 1).
1021
1002
"""
1022
1003
is_datetimelike = needs_i8_conversion (values .dtype )
1023
- values = _get_values_for_rank (values )
1004
+ values = _ensure_data (values )
1005
+
1006
+ if values .dtype .kind in ["i" , "u" , "f" ]:
1007
+ # rank_t includes only object, int64, uint64, float64
1008
+ dtype = values .dtype .kind + "8"
1009
+ values = values .astype (dtype , copy = False )
1010
+
1024
1011
if values .ndim == 1 :
1025
1012
ranks = algos .rank_1d (
1026
1013
values ,
@@ -1765,7 +1752,7 @@ def safe_sort(
1765
1752
1766
1753
if sorter is None :
1767
1754
# mixed types
1768
- hash_klass , values = _get_data_algo (values )
1755
+ hash_klass , values = _get_hashtable_algo (values )
1769
1756
t = hash_klass (len (values ))
1770
1757
t .map_locations (values )
1771
1758
sorter = ensure_platform_int (t .lookup (ordered ))
0 commit comments