diff --git a/narwhals/pandas_like/expr.py b/narwhals/pandas_like/expr.py index a8457fa534..e94aa2f3f2 100644 --- a/narwhals/pandas_like/expr.py +++ b/narwhals/pandas_like/expr.py @@ -48,7 +48,7 @@ def from_column_names( return cls( lambda df: [ PandasSeries( - df._dataframe.loc[:, column_name], + df._dataframe[column_name], implementation=implementation, ) for column_name in column_names diff --git a/tests/tpch_q1_test.py b/tests/tpch_q1_test.py index e07dbea2a8..97a3d8d88a 100644 --- a/tests/tpch_q1_test.py +++ b/tests/tpch_q1_test.py @@ -2,10 +2,10 @@ import os from datetime import datetime -from typing import Any from unittest import mock -import polars +import pandas as pd +import polars as pl import pytest import narwhals as nw @@ -13,13 +13,15 @@ @pytest.mark.parametrize( - "df_raw", - [ - (polars.read_parquet("tests/data/lineitem.parquet").to_pandas()), - polars.scan_parquet("tests/data/lineitem.parquet"), - ], + "library", + ["pandas", "polars"], ) -def test_q1(df_raw: Any) -> None: +@pytest.mark.filterwarnings("ignore:.*Passing a BlockManager.*:DeprecationWarning") +def test_q1(library: str) -> None: + if library == "pandas": + df_raw = pd.read_parquet("tests/data/lineitem.parquet") + elif library == "polars": + df_raw = pl.scan_parquet("tests/data/lineitem.parquet") var_1 = datetime(1998, 9, 2) df = nw.LazyFrame(df_raw) query_result = ( @@ -73,14 +75,10 @@ def test_q1(df_raw: Any) -> None: compare_dicts(result, expected) -@pytest.mark.parametrize( - "df_raw", - [ - (polars.read_parquet("tests/data/lineitem.parquet").to_pandas()), - ], -) @mock.patch.dict(os.environ, {"NARWHALS_FORCE_GENERIC": "1"}) -def test_q1_w_pandas_agg_generic_path(df_raw: Any) -> None: +@pytest.mark.filterwarnings("ignore:.*Passing a BlockManager.*:DeprecationWarning") +def test_q1_w_pandas_agg_generic_path() -> None: + df_raw = pl.read_parquet("tests/data/lineitem.parquet").to_pandas() var_1 = datetime(1998, 9, 2) df = nw.LazyFrame(df_raw) query_result = (