-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
ENH: Add case_when method #56059
ENH: Add case_when method #56059
Conversation
pre-commit.ci autofix |
@rhshadrach had issues with the previous pr #55390 and created this one. If there is a way to reconnect to the old one, kindly advise me on the approach. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the implementation is looking pretty good - but tests can be expanded on. Would it be okay if I pushed some tests to your branch?
@rhshadrach made changes based on your feedback. Looking forward to your reviews |
Thanks for the changes. I think this is looking good - but want to add more tests when I get a chance. In the meantime, cc @pandas-dev/pandas-core for any thoughts/feedback here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just added a comment with respect to typing, and also another check to validate arguments.
Thoughts:
|
@jbrockmendel in response to your comments:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with the typing changes and changes to the API, but I will let other maintainers take care of the rest of this one.
Strong preference for method |
pandas/core/case_when.py
Outdated
updated_replacements.append(replacement) | ||
replacements = updated_replacements | ||
if (default is not None) and isinstance(default, ABCSeries): | ||
default = default.astype(common_dtypes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might upcast, thoughts related to PDEP6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is related to PDEP6, we are creating a new Series and not doing something like setitem.
…ails (#56589) Add McKinney (2010) reference, DOI, team website, & more keywords
* REF: fix can_use_libjoin check * DOC: docstring for can_use_libjoin * Make can_use_libjoin checks more-correct * avoid allocating mapping in monotonic cases * fix categorical memory usage tests * catch decimal.InvalidOperation --------- Co-authored-by: Luke Manley <[email protected]>
* TYP: fix some annotations * pyupgrade
* BUG: Series.to_numpy raising for arrow floats to numpy floats * Fixup
How does this handle attrs/_metadata/flags when given mismatched args with mismatched attrs/_metadat/flags? |
@jbrockmendel i am unfamiliar with your question. Kindly share an example to help me understand. |
@samukweku your latest rebase threw something off here, the diff is too large. Could you take a look? |
The handling off metadata is dispatched to mask in this case, so we should be good |
Fix PR05 error
@rhshadrach yes pls feel free to add more tests |
merging this, we can always add tests after if necessary |
thx for staying with us @samukweku |
Something went wrong ... Please have a look at my logs. |
(cherry picked from commit e3a55a4)
ENH: Add case_when method (#56059) (cherry picked from commit e3a55a4) Co-authored-by: Samuel Oranyeli <[email protected]>
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Continues the work started by @ELHoussineT(#50343)
pd.Series.mask
under the hood