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

Adding string to parameters for replace function #230

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

Bidek56
Copy link
Collaborator

@Bidek56 Bidek56 commented Jun 13, 2024

Adding string to parameters for expr replace function
Adding replace tests

@Bidek56 Bidek56 self-assigned this Jun 13, 2024
@Bidek56 Bidek56 added the bug Something isn't working label Jun 13, 2024
Comment on lines +1208 to +1212
pl
.col("b")
.replace(["a", "b"], ["c", "d"], "e", pl.Utf8)
.alias("replaced"),
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it'd be a bit more readable if we took in a object/map here instead of the array. (this could totally be done in a follow up pr though.

pl.col("a").replace({ 1: 11, 2: 12 }, 10, pl.Int64)
pl.col("b").replace({ a: "c", b: "d" }, "e", pl.Utf8)

also, i think using an object for the additional parameters would make things more readable

pl.col("a").replace({ 1: 11, 2: 12 }, {
  defaultValue: 10,
  returnType: pl.Int64,
})

Copy link
Collaborator Author

@Bidek56 Bidek56 Jun 13, 2024

Choose a reason for hiding this comment

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

It would be more readable but I want to test list as param.
Python version supports both list and dict, hence we need to support both and test for it.
We can add another test using object if you like.

@universalmind303 universalmind303 merged commit 4c73524 into pola-rs:main Jun 24, 2024
9 checks passed
@Bidek56 Bidek56 deleted the replace-str-list branch July 9, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants