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

narwhalify SetValueTransformer #398

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

davidhopkinson26
Copy link
Contributor

@davidhopkinson26 davidhopkinson26 commented Mar 26, 2025

Narwhalifying SetValueTransformer for polars compatibility.

Also extending testing to cover more values being set (was previously just testing setting a string value)

Draft because for integers we get int32 return while expected is currently int64. <- edited test to cast to int32 as transformer does.

@davidhopkinson26 davidhopkinson26 linked an issue Mar 26, 2025 that may be closed by this pull request
@davidhopkinson26 davidhopkinson26 marked this pull request as ready for review March 26, 2025 13:55
df["a"] = "a"
df["b"] = "a"
@pytest.mark.parametrize("library", ["pandas", "polars"])
@pytest.mark.parametrize("value", ["a", 1, 1.0, None])
Copy link
Contributor

Choose a reason for hiding this comment

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

I can see that in the transformer we allow all types and we dont have options for nans. So should we also add a missing value test here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep fair point. Was kind of expecting this to break for polars but it works still! 1251699

@@ -42,7 +48,8 @@ def __init__(

super().__init__(columns=columns, copy=copy, **kwargs)

def transform(self, X: pd.DataFrame) -> pd.DataFrame:
@nw.narwhalify
def transform(self, X: FrameT) -> FrameT:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the docstring to match pd/pl.DataFrame

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@ChristinaKatsiafa ChristinaKatsiafa left a comment

Choose a reason for hiding this comment

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

I am happy with the changes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

narwhalify SetValueTransformer
2 participants