From 7bd9a14a18555c5ba2a7262e485dddfe6ae19f8c Mon Sep 17 00:00:00 2001 From: pwwang Date: Mon, 12 Dec 2022 09:30:54 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20`ntile`=20non-balanced=20b?= =?UTF-8?q?ins=20by=20using=20`pd.qcut`,=20instead=20of=20`pd.cut`=20(pwwa?= =?UTF-8?q?ng/datar#161)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- datar_pandas/api/dplyr/_rank.py | 2 +- datar_pandas/pandas.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/datar_pandas/api/dplyr/_rank.py b/datar_pandas/api/dplyr/_rank.py index 53c8a25..1820570 100644 --- a/datar_pandas/api/dplyr/_rank.py +++ b/datar_pandas/api/dplyr/_rank.py @@ -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) diff --git a/datar_pandas/pandas.py b/datar_pandas/pandas.py index ee39359..7f72b77 100644 --- a/datar_pandas/pandas.py +++ b/datar_pandas/pandas.py @@ -37,6 +37,7 @@ crosstab, concat, cut, + qcut, isna, isnull, merge, @@ -73,6 +74,7 @@ def get_obj(grouped): crosstab, concat, cut, + qcut, isna, isnull, merge,