Skip to content

Commit

Permalink
FEAT: Add implementation of cut [upstream] (modin-project#10)
Browse files Browse the repository at this point in the history
Note for upstream: upstream should implement cut, but default to pandas instead
of raising NotImplementedError

Signed-off-by: mvashishtha <mahesh@ponder.io>
  • Loading branch information
mvashishtha authored and vnlitvinov committed Mar 16, 2023
1 parent 2035f6f commit 49b5e08
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modin/pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
warnings.simplefilter("ignore")
from pandas import (
eval,
cut,
factorize,
test,
date_range,
Expand Down Expand Up @@ -254,6 +253,7 @@ def init_remote_ray(partition):
wide_to_long,
to_timedelta,
pivot_table,
cut,
)

from .plotting import Plotting as plotting
Expand Down Expand Up @@ -374,6 +374,7 @@ def init_remote_ray(partition):
"Float32Dtype",
"Float64Dtype",
"from_dummies",
"cut",
]

del pandas, Parameter
22 changes: 22 additions & 0 deletions modin/pandas/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,3 +755,25 @@ def to_timedelta(arg, unit=None, errors="raise"): # noqa: PR01, RT01, D200
query_compiler = arg._query_compiler.to_timedelta(unit=unit, errors=errors)
return Series(query_compiler=query_compiler)
return pandas.to_timedelta(arg, unit=unit, errors=errors)


def cut(
x,
bins,
right: bool = True,
labels=None,
retbins: bool = False,
precision: int = 3,
include_lowest: bool = False,
duplicates: str = "raise",
ordered: bool = True,
):
if isinstance(x, DataFrame):
raise ValueError("Input array must be 1 dimensional")
if not isinstance(x, Series):
NotImplementedError("cut only supports cutting modin series")
return Series(
query_compiler=x._query_compiler.cut(
bins, right, labels, retbins, precision, include_lowest, duplicates, ordered
)
)

0 comments on commit 49b5e08

Please sign in to comment.