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

add cols to mapcols and mapcols! #3386

Merged
merged 12 commits into from
Oct 17, 2023
Merged

add cols to mapcols and mapcols! #3386

merged 12 commits into from
Oct 17, 2023

Conversation

bkamins
Copy link
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 added this to the 1.7 milestone Oct 10, 2023
@bkamins
Copy link
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.

src/abstractdataframe/iteration.jl Outdated Show resolved Hide resolved
src/abstractdataframe/iteration.jl Outdated Show resolved Hide resolved
src/abstractdataframe/iteration.jl Outdated Show resolved Hide resolved
src/abstractdataframe/iteration.jl Show resolved Hide resolved
src/abstractdataframe/iteration.jl Outdated Show resolved Hide resolved
src/abstractdataframe/iteration.jl Outdated Show resolved Hide resolved
test/iteration.jl Show resolved Hide resolved
test/iteration.jl Outdated Show resolved Hide resolved
else
picked = Set(names(df, cols))
apply = Bool[name in picked for name in names(df)]
@assert length(apply) == ncol(df)
Copy link
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
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
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
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
6 of 7 checks passed
@bkamins bkamins deleted the bk/mapcols branch October 17, 2023 09:57
@bkamins
Copy link
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