Skip to content

Commit

Permalink
🐛 Fix ntile non-balanced bins by using pd.qcut, instead of `pd.cu…
Browse files Browse the repository at this point in the history
  • Loading branch information
pwwang committed Dec 12, 2022
1 parent 9907c30 commit 7bd9a14
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datar_pandas/api/dplyr/_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _(x, n):
return Categorical([np.nan] * x.size)

n = min(n, x.size)
return pd.cut(x, n, labels=np.arange(n) + 1)
return pd.qcut(x, n, labels=np.arange(n) + 1)


@_ntile.register(GroupBy)
Expand Down
2 changes: 2 additions & 0 deletions datar_pandas/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
crosstab,
concat,
cut,
qcut,
isna,
isnull,
merge,
Expand Down Expand Up @@ -73,6 +74,7 @@ def get_obj(grouped):
crosstab,
concat,
cut,
qcut,
isna,
isnull,
merge,
Expand Down

0 comments on commit 7bd9a14

Please sign in to comment.