Skip to content

Commit 5bd5ba7

Browse files
jbrockmendelNico Cernek
authored and
Nico Cernek
committed
add types tot rank_1d_, rank_2d (pandas-dev#28978)
1 parent 8c03caa commit 5bd5ba7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pandas/_libs/algos_rank_helper.pxi.in

+4-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dtypes = [('object', 'object', 'Infinity()', 'NegInfinity()'),
2424

2525
@cython.wraparound(False)
2626
@cython.boundscheck(False)
27-
def rank_1d_{{dtype}}(object in_arr, ties_method='average',
27+
def rank_1d_{{dtype}}({{ctype}}[:] in_arr, ties_method='average',
2828
ascending=True, na_option='keep', pct=False):
2929
"""
3030
Fast NaN-friendly version of scipy.stats.rankdata
@@ -189,7 +189,7 @@ def rank_1d_{{dtype}}(object in_arr, ties_method='average',
189189
return ranks
190190

191191

192-
def rank_2d_{{dtype}}(object in_arr, axis=0, ties_method='average',
192+
def rank_2d_{{dtype}}({{ctype}}[:, :] in_arr, axis=0, ties_method='average',
193193
ascending=True, na_option='keep', pct=False):
194194
"""
195195
Fast NaN-friendly version of scipy.stats.rankdata
@@ -226,12 +226,10 @@ def rank_2d_{{dtype}}(object in_arr, axis=0, ties_method='average',
226226

227227
keep_na = na_option == 'keep'
228228

229-
in_arr = np.asarray(in_arr)
230-
231229
if axis == 0:
232-
values = in_arr.T.copy()
230+
values = np.asarray(in_arr).T.copy()
233231
else:
234-
values = in_arr.copy()
232+
values = np.asarray(in_arr).copy()
235233

236234
{{if dtype == 'object'}}
237235
if values.dtype != np.object_:

0 commit comments

Comments
 (0)