-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH:Create Set Operations #42177
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
Comments
I believe this is mostly a duplicate of #4480, which is the same thing but for I'll leave this issue open for now, since it's not technically a duplicate and I may be missing something. |
You can do most of these with a single line already (perhaps not as intuitive but possible)! Using your example of The 'OR' function to get {'a': 1 2 3 4} can be accomplished with The 'AND' function to get {'a': 1 3} can be accomplished with The 'XOR' function to get {'a': 2 4} would require a bit more manipulation, but still simple enough with a different approach imho Not sure what taking the NOT of a dataframe would mean, but perhaps the |
I was thinking more A.not(B) would be like A[~A.isin(B)]. I just think it would be more intuitive that way. |
Hmm yeah I see what you mean. I would probably just do +1 for it would be nice to have some functionality in subsetting dataframes that is more intuitive and doesn't require use of index/col names |
I don't think that the pain of using less readable syntax is worth the legwork this will take to implement, but that's for the contributor to decide. |
'NOT' wouldn't work for the same reason it doesn't work on |
This is set difference. The elements of A that are not shared with B i.e. relative complement. |
Is your feature request related to a problem?
I wish to take the AND, OR, XOR, and NOT of dataframes. Of course I could do this manually but an inbuilt way would be far cleaner and elegant.
Possible Solution
Example 1:
A = {'a': 1 2 3}
B = {'a': 1 3 4}
pandas.xor(A,B, on = "a")
{'a': 2 4}
Example 2:
A.or( B, on= "a")
{'a': 1 2 3 4}
Example 3:
A.and(B,on='a')
{'a': 1 3}
API breaking implications
It will not affect the API it is just a convenience feature.
Additional context
Typically when comparing data from 2 sources, fields will not correlate and need to be cleaned through basic and, or, nor, and not, and xor operations. This would speed up greatly those tasks.
The text was updated successfully, but these errors were encountered: