Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions pandas/_libs/algos_rank_helper.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dtypes = [('object', 'object', 'Infinity()', 'NegInfinity()'),

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


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

keep_na = na_option == 'keep'

in_arr = np.asarray(in_arr)

if axis == 0:
values = in_arr.T.copy()
values = np.asarray(in_arr).T.copy()
else:
values = in_arr.copy()
values = np.asarray(in_arr).copy()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because without it cython raises at compile-time because it in_arr and values have different types


{{if dtype == 'object'}}
if values.dtype != np.object_:
Expand Down