Skip to content

Commit

Permalink
fixup pandas as well
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Mar 16, 2024
1 parent 1268b98 commit 23ec222
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions narwhals/pandas_like/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def filter(
self,
*predicates: IntoPandasExpr | Iterable[IntoPandasExpr],
) -> Self:
from narwhals.pandas_like.namespace import Namespace
from narwhals.pandas_like.namespace import PandasNamespace

plx = Namespace(self._implementation)
plx = PandasNamespace(self._implementation)
expr = plx.all_horizontal(*predicates)
# Safety: all_horizontal's expression only returns a single column.
mask = expr._call(self)[0]
Expand Down
2 changes: 1 addition & 1 deletion narwhals/pandas_like/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from narwhals.pandas_like.typing import IntoPandasExpr


class Namespace:
class PandasNamespace:
Int64 = dtypes.Int64
Int32 = dtypes.Int32
Int16 = dtypes.Int16
Expand Down
11 changes: 7 additions & 4 deletions narwhals/pandas_like/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,13 @@ def parse_into_exprs(

def parse_into_expr(implementation: str, into_expr: IntoPandasExpr) -> PandasExpr:
from narwhals.expression import Expr
from narwhals.pandas_like.namespace import Namespace
from narwhals.pandas_like.expr import PandasExpr
from narwhals.pandas_like.namespace import PandasNamespace

plx = Namespace(implementation=implementation)
plx = PandasNamespace(implementation=implementation)

if isinstance(into_expr, PandasExpr):
return into_expr
if isinstance(into_expr, Expr):
return into_expr._call(plx)
if isinstance(into_expr, str):
Expand Down Expand Up @@ -141,10 +144,10 @@ def evaluate_into_exprs(

def register_expression_call(expr: ExprT, attr: str, *args: Any, **kwargs: Any) -> ExprT:
from narwhals.pandas_like.expr import PandasExpr
from narwhals.pandas_like.namespace import Namespace
from narwhals.pandas_like.namespace import PandasNamespace
from narwhals.pandas_like.series import PandasSeries

plx = Namespace(implementation=expr._implementation)
plx = PandasNamespace(implementation=expr._implementation)

def func(df: PandasDataFrame) -> list[PandasSeries]:
out: list[PandasSeries] = []
Expand Down

0 comments on commit 23ec222

Please sign in to comment.