Skip to content

add cols to mapcols and mapcols!#3386

Merged
bkamins merged 12 commits intomainfrom
bk/mapcols
Oct 17, 2023
Merged

add cols to mapcols and mapcols!#3386
bkamins merged 12 commits intomainfrom
bk/mapcols

Conversation

@bkamins
Copy link
Copy Markdown
Member

@bkamins bkamins commented Oct 10, 2023

add cols kwarg to mapcols and mapcols! similarly like we recently did for column renaming.
This is a useful addition for cases when e.g. one wants to transform only columns meeting some condition and keep the column order unchanged.

@bkamins bkamins requested a review from nalimilan October 10, 2023 06:58
@bkamins bkamins added this to the 1.7 milestone Oct 10, 2023
@bkamins
Copy link
Copy Markdown
Member Author

bkamins commented Oct 10, 2023

@nalimilan - do you know why DataFrames.jl tests on nightly keep failing? I though that median PR you made should fix them.

else
picked = Set(names(df, cols))
apply = Bool[name in picked for name in names(df)]
@assert length(apply) == ncol(df)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any reason why this could be false?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No - it is just that later we use zip which does not check this invariant.

If you prefer I can remove it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well it seems to me that the comprehension that creates apply already guarantees that invariant (unless names is broken but then we have more serious problems...).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

OK - I removed the @assert

@bkamins bkamins merged commit 1a5da8a into main Oct 17, 2023
@bkamins bkamins deleted the bk/mapcols branch October 17, 2023 09:57
@bkamins
Copy link
Copy Markdown
Member Author

bkamins commented Oct 17, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants