Skip to content

Commit

Permalink
wip;
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Mar 18, 2024
1 parent 2a39a86 commit 60e7898
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
3 changes: 1 addition & 2 deletions narwhals/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from narwhals.group_by import GroupBy
from narwhals.series import Series
from narwhals.typing import IntoExpr
from narwhals.typing import T


class BaseFrame:
Expand Down Expand Up @@ -208,7 +207,7 @@ def to_dict(self, *, as_series: bool = True) -> dict[str, Any]:
class LazyFrame(BaseFrame):
def __init__(
self,
df: T,
df: Any,
*,
implementation: str | None = None,
) -> None:
Expand Down
2 changes: 1 addition & 1 deletion narwhals/pandas_like/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def filter(
# Safety: all_horizontal's expression only returns a single column.
mask = expr._call(self)[0]
_mask = validate_dataframe_comparand(mask)
return self._from_dataframe(self._dataframe.loc[_mask])
return self._from_dataframe(self._dataframe[_mask])

def with_columns(
self,
Expand Down
12 changes: 6 additions & 6 deletions narwhals/pandas_like/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ def validate_dataframe_comparand(other: Any) -> Any:
from narwhals.pandas_like.dataframe import PandasDataFrame
from narwhals.pandas_like.series import PandasSeries

if isinstance(other, list) and len(other) > 1:
# e.g. `plx.all() + plx.all()`
msg = "Multi-output expressions are not supported in this context"
raise ValueError(msg)
if isinstance(other, list):
other = other[0]
if isinstance(other, PandasDataFrame):
return NotImplemented
if isinstance(other, PandasSeries):
if other.len() == 1:
# broadcast
return item(other._series)
return other._series
if isinstance(other, list) and len(other) > 1:
# e.g. `plx.all() + plx.all()`
msg = "Multi-output expressions are not supported in this context"
raise ValueError(msg)
if isinstance(other, list):
other = other[0]
return other


Expand Down
8 changes: 3 additions & 5 deletions tpch/q1.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ def q1(df_raw: Any) -> Any:
return nw.to_native(result.collect())


df = pd.read_parquet("../tpch-data/s1/lineitem.parquet", dtype_backend="pyarrow")
breakpoint()
# df["l_shipdate"] = pd.to_datetime(df["l_shipdate"])
print(q1(df))
df = polars.scan_parquet("../tpch-data/s1/lineitem.parquet")
df = pd.read_parquet(
"../tpch-data/s1/lineitem.parquet", dtype_backend="pyarrow", engine="pyarrow"
)
print(q1(df))

0 comments on commit 60e7898

Please sign in to comment.