-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat(python): Add DataFrame.iter_columns
#12653
Conversation
66d9a6c
to
f07236c
Compare
f07236c
to
5284153
Compare
I'm in favor of adding the explicit |
5284153
to
084a259
Compare
I think it is worth the deprecation as iteration over a 2D data structure is ambiguous. |
In that sense it would match what we do with our implementation of Overall, I think removal will make For example, I expect collection-type objects to implement You could argue also Anyway, that's my two cents and I'll leave it up to you to decide. The PR in its current form can be merged regardless 👍 |
I'd also strongly suggest not deprecating Being able to directly iterate a collection-like structure is definitely expected for Python objects. Given that DataFrames are column-native, it feels reasonable/expected to iterate over them as Series. It's also not really ambiguous - if we returned Python-native lists here (instead of Series) then there might be some (minor) potential for confusion, but that's not the case. |
Ok, let's be conservative for now. Can we revert the deprecation and think about it a little bit more? |
yup - there's no deprecation in this PR at the moment, it just adds |
Actually... I'd make one addition/change; Then, in either case, we will be consistent in our default behaviour for both row/col iteration types (returning py-native data when iterating from python), and Series iteration becomes explicit instead of implicit. Should cover all the bases pretty cleanly. |
I am not very fond of materializing to python on We don't have a |
I agree with Ritchie on this one - I don't think the discussion of Python native objects vs Polars objects applies here. I'm going to go ahead and merge this. Nice to have an explicit way of iterating columns! |
DataFrame.iter_columns
closes #12630
Demo:EDIT
demo above it outdated, this PR now just adds
iter_columns
without deprecating anything