diff --git a/narwhals/pandas_like/utils.py b/narwhals/pandas_like/utils.py index 9c3d25ee43..d31f0184f1 100644 --- a/narwhals/pandas_like/utils.py +++ b/narwhals/pandas_like/utils.py @@ -119,8 +119,16 @@ def evaluate_into_expr( """ Return list of raw columns. """ - expr = parse_into_expr(df._implementation, into_expr) - return expr._call(df) + from narwhals.pandas_like.expr import PandasExpr + from narwhals.pandas_like.series import PandasSeries + + if isinstance(into_expr, PandasSeries): + return [into_expr] + if isinstance(into_expr, str): + return [df[into_expr]] + if isinstance(into_expr, PandasExpr): + return into_expr._call(df) + raise AssertionError def evaluate_into_exprs( diff --git a/tests/test_common.py b/tests/test_common.py index 0cef132645..1c1b731190 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -233,6 +233,7 @@ def test_accepted_dataframes() -> None: @pytest.mark.parametrize("df_raw", [df_polars, df_pandas, df_mpd]) +@pytest.mark.filterwarnings("ignore:.*Passing a BlockManager.*:DeprecationWarning") def test_convert_pandas(df_raw: Any) -> None: result = nw.DataFrame(df_raw).to_pandas() expected = pd.DataFrame({"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]}) diff --git a/tests/tpch_q1_test.py b/tests/tpch_q1_test.py index 97a3d8d88a..a5d421c677 100644 --- a/tests/tpch_q1_test.py +++ b/tests/tpch_q1_test.py @@ -20,6 +20,7 @@ def test_q1(library: str) -> None: if library == "pandas": df_raw = pd.read_parquet("tests/data/lineitem.parquet") + df_raw["l_shipdate"] = pd.to_datetime(df_raw["l_shipdate"]) elif library == "polars": df_raw = pl.scan_parquet("tests/data/lineitem.parquet") var_1 = datetime(1998, 9, 2) @@ -78,7 +79,8 @@ def test_q1(library: str) -> None: @mock.patch.dict(os.environ, {"NARWHALS_FORCE_GENERIC": "1"}) @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() + df_raw = pd.read_parquet("tests/data/lineitem.parquet") + df_raw["l_shipdate"] = pd.to_datetime(df_raw["l_shipdate"]) var_1 = datetime(1998, 9, 2) df = nw.LazyFrame(df_raw) query_result = (