Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Preserve name when casting to Enum #14320

Merged
merged 4 commits into from
Feb 6, 2024

Conversation

mcrumiller
Copy link
Contributor

Resolves #14318.

import polars as pl

dtype1 = pl.Enum(["a", "b"])
dtype2 = pl.Enum(["a", "b", "Null"])

s = pl.Series(name="x", values=["a", "b", None], dtype=dtype1)
print(s.name)
x

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Feb 6, 2024
@mcrumiller mcrumiller marked this pull request as ready for review February 6, 2024 18:07
Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just one comment about the test!

@@ -579,25 +579,29 @@ def test_strict_cast_string_and_binary(


@pytest.mark.parametrize(
"dtype_out",
("dtype_in", "dtype_out"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you just make a separate test test_cast_enum_name_retention? That should make things a bit cleaner.

Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@stinodego stinodego merged commit 6fc0395 into pola-rs:main Feb 6, 2024
22 checks passed
@mcrumiller mcrumiller deleted the enum-cast-name branch February 6, 2024 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enum -> Enum cast makes column name disappear
2 participants