Skip to content

Commit

Permalink
feat: allow for "import narwhals.stable.v1.selectors as cs" (#1459)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli authored Nov 28, 2024
1 parent c08a09d commit ec76fda
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
2 changes: 2 additions & 0 deletions narwhals/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from narwhals import dependencies
from narwhals import dtypes
from narwhals import exceptions
from narwhals import selectors
from narwhals import stable
Expand Down Expand Up @@ -107,6 +108,7 @@
"concat",
"concat_str",
"dependencies",
"dtypes",
"exceptions",
"from_arrow",
"from_dict",
Expand Down
10 changes: 10 additions & 0 deletions narwhals/selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,13 @@ def all() -> Expr:
└─────┴─────┴───────┘
"""
return Selector(lambda plx: plx.selectors.all())


__all__ = [
"by_dtype",
"numeric",
"boolean",
"string",
"categorical",
"all",
]
2 changes: 2 additions & 0 deletions narwhals/stable/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from narwhals.functions import show_versions
from narwhals.schema import Schema as NwSchema
from narwhals.series import Series as NwSeries
from narwhals.stable.v1 import dtypes
from narwhals.stable.v1.dtypes import Array
from narwhals.stable.v1.dtypes import Boolean
from narwhals.stable.v1.dtypes import Categorical
Expand Down Expand Up @@ -3232,6 +3233,7 @@ def from_dict(
"concat",
"concat_str",
"dependencies",
"dtypes",
"exceptions",
"from_arrow",
"from_dict",
Expand Down
17 changes: 17 additions & 0 deletions narwhals/stable/v1/selectors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from __future__ import annotations

from narwhals.selectors import all
from narwhals.selectors import boolean
from narwhals.selectors import by_dtype
from narwhals.selectors import categorical
from narwhals.selectors import numeric
from narwhals.selectors import string

__all__ = [
"by_dtype",
"numeric",
"boolean",
"string",
"categorical",
"all",
]
12 changes: 6 additions & 6 deletions tests/selectors_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import pytest

import narwhals.stable.v1 as nw
from narwhals.selectors import all
from narwhals.selectors import boolean
from narwhals.selectors import by_dtype
from narwhals.selectors import categorical
from narwhals.selectors import numeric
from narwhals.selectors import string
from narwhals.stable.v1.selectors import all
from narwhals.stable.v1.selectors import boolean
from narwhals.stable.v1.selectors import by_dtype
from narwhals.stable.v1.selectors import categorical
from narwhals.stable.v1.selectors import numeric
from narwhals.stable.v1.selectors import string
from tests.utils import PYARROW_VERSION
from tests.utils import Constructor
from tests.utils import assert_equal_data
Expand Down

0 comments on commit ec76fda

Please sign in to comment.