diff --git a/narwhals/dataframe.py b/narwhals/dataframe.py index 66dc4d5de..6bada59f7 100644 --- a/narwhals/dataframe.py +++ b/narwhals/dataframe.py @@ -2912,7 +2912,7 @@ def collect(self) -> DataFrame[Any]: | Use `.to_native` to see native output | └───────────────────────────────────────┘ >>> df = lf.group_by("a").agg(nw.all().sum()).collect() - >>> df.to_native().sort("a") + >>> df.native.sort("a") shape: (3, 3) ┌─────┬─────┬─────┐ │ a ┆ b ┆ c │ diff --git a/narwhals/stable/v1/__init__.py b/narwhals/stable/v1/__init__.py index e17875507..e0f4dcb0a 100644 --- a/narwhals/stable/v1/__init__.py +++ b/narwhals/stable/v1/__init__.py @@ -416,7 +416,7 @@ def collect(self) -> DataFrame[Any]: | Use `.to_native` to see native output | └───────────────────────────────────────┘ >>> df = lf.group_by("a").agg(nw.all().sum()).collect() - >>> df.to_native().sort("a") # doctest:+SKIP + >>> df.native.sort("a") shape: (3, 3) ┌─────┬─────┬─────┐ │ a ┆ b ┆ c │ diff --git a/tests/from_pycapsule_test.py b/tests/from_pycapsule_test.py index 7d91a44f3..b48db2c36 100644 --- a/tests/from_pycapsule_test.py +++ b/tests/from_pycapsule_test.py @@ -16,7 +16,7 @@ def test_from_arrow_to_arrow() -> None: df = nw.from_native(pl.DataFrame({"ab": [1, 2, 3], "ba": [4, 5, 6]}), eager_only=True) result = nw.from_arrow(df, native_namespace=pa) - assert isinstance(result.to_native(), pa.Table) + assert isinstance(result.native, pa.Table) expected = {"ab": [1, 2, 3], "ba": [4, 5, 6]} assert_equal_data(result, expected) @@ -27,7 +27,7 @@ def test_from_arrow_to_polars(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.delitem(sys.modules, "pandas") df = nw.from_native(tbl, eager_only=True) result = nw.from_arrow(df, native_namespace=pl) - assert isinstance(result.to_native(), pl.DataFrame) + assert isinstance(result.native, pl.DataFrame) expected = {"ab": [1, 2, 3], "ba": [4, 5, 6]} assert_equal_data(result, expected) assert "pandas" not in sys.modules @@ -37,7 +37,7 @@ def test_from_arrow_to_polars(monkeypatch: pytest.MonkeyPatch) -> None: def test_from_arrow_to_pandas() -> None: df = nw.from_native(pa.table({"ab": [1, 2, 3], "ba": [4, 5, 6]}), eager_only=True) result = nw.from_arrow(df, native_namespace=pd) - assert isinstance(result.to_native(), pd.DataFrame) + assert isinstance(result.native, pd.DataFrame) expected = {"ab": [1, 2, 3], "ba": [4, 5, 6]} assert_equal_data(result, expected) diff --git a/tests/stable_api_test.py b/tests/stable_api_test.py index 414b20ad0..108c0a519 100644 --- a/tests/stable_api_test.py +++ b/tests/stable_api_test.py @@ -49,7 +49,7 @@ def test_renamed_taxicab_norm_dataframe(constructor: Constructor) -> None: def func(df_any: Any) -> Any: df = nw_v1.from_native(df_any) df = df._l1_norm() - return df.to_native() + return df.native result = nw_v1.from_native(func(constructor({"a": [1, 2, 3, -4, 5]}))) expected = {"a": [15]} diff --git a/tests/utils_test.py b/tests/utils_test.py index fb668b4d2..dcfbe4acd 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -102,7 +102,7 @@ def test_maybe_reset_index_pandas() -> None: result = nw.maybe_reset_index(pandas_df) expected = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) assert_frame_equal(nw.to_native(result), expected) - assert result.to_native() is pandas_df.to_native() + assert result.native is pandas_df.native pandas_series = nw.from_native( pd.Series([1, 2, 3], index=[7, 8, 9]), series_only=True ) @@ -113,7 +113,7 @@ def test_maybe_reset_index_pandas() -> None: result_s = nw.maybe_reset_index(pandas_series) expected_s = pd.Series([1, 2, 3]) assert_series_equal(nw.to_native(result_s), expected_s) - assert result_s.to_native() is pandas_series.to_native() + assert result_s.native is pandas_series.native def test_maybe_reset_index_polars() -> None: