Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
DeaMariaLeon committed Oct 24, 2024
1 parent 220b9fa commit c021267
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions narwhals/_pandas_like/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from narwhals._pandas_like.namespace import PandasLikeNamespace
from narwhals.typing import DTypes
from narwhals.utils import Implementation
from narwhals.dtypes import DType


class PandasLikeExpr:
Expand Down Expand Up @@ -386,6 +387,19 @@ def gather_every(self: Self, n: int, offset: int = 0) -> Self:

def mode(self: Self) -> Self:
return reuse_series_implementation(self, "mode")

def map_batches(self, function: Callable[[Any], Self], return_dtype: DType | None = None, *args: Any, **kwargs: Any) -> Self:
breakpoint()
return self.__class__(
lambda df: [function(series) for series in self._call(df)],
depth=self._depth + 1,
function_name=self._function_name + "->map_batches",
root_names=self._root_names,
output_names=self._output_names,
implementation=self._implementation,
backend_version=self._backend_version,
dtypes=self._dtypes,
)

@property
def str(self: Self) -> PandasLikeExprStringNamespace:
Expand Down
7 changes: 7 additions & 0 deletions narwhals/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,13 @@ def std(self, *, ddof: int = 1) -> Self:
"""
return self.__class__(lambda plx: self._call(plx).std(ddof=ddof))




def map_batches(self, function: Callable[[Any], Self], return_dtype: DType | None = None, *args: Any, **kwargs: Any) -> Self:
return self.__class__(lambda plx: self._call(plx).map_batches(function))


def sum(self) -> Expr:
"""
Expand Down

0 comments on commit c021267

Please sign in to comment.