Skip to content

Commit

Permalink
test(python): Add test on selecting Enum columns (#14628)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-peters authored Feb 21, 2024
1 parent a0bcb2b commit 4f5436a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion py-polars/tests/unit/datatypes/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import polars as pl
from polars import StringCache
from polars.testing import assert_series_equal
from polars.testing import assert_frame_equal, assert_series_equal


def test_enum_creation() -> None:
Expand Down Expand Up @@ -402,3 +402,22 @@ def test_enum_cast_from_other_integer_dtype_oob() -> None:
pl.ComputeError, match="conversion from `u64` to `u32` failed in column"
):
series.cast(enum_dtype)


def test_enum_creating_col_expr() -> None:
df = pl.DataFrame(
{
"col1": ["a", "b", "c"],
"col2": ["d", "e", "f"],
"col3": ["g", "h", "i"],
},
schema={
"col1": pl.Enum(["a", "b", "c"]),
"col2": pl.Categorical(),
"col3": pl.Enum(["g", "h", "i"]),
},
)

out = df.select(pl.col(pl.Enum))
expected = df.select("col1", "col3")
assert_frame_equal(out, expected)

0 comments on commit 4f5436a

Please sign in to comment.