Skip to content

REF/TYP: implement NDFrameApply #41067

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

Merged
merged 1 commit into from
Apr 28, 2021
Merged

Conversation

jbrockmendel
Copy link
Member

if called from GroupByApply or ResamplerWindowApply, these would raise

@jbrockmendel jbrockmendel added Apply Apply, Aggregate, Transform, Map Refactor Internal refactoring of code labels Apr 22, 2021
@jreback jreback added this to the 1.3 milestone Apr 22, 2021
@jreback
Copy link
Contributor

jreback commented Apr 22, 2021

looks fine, cc @rhshadrach

Comment on lines +467 to -479
# Caller is responsible for checking isinstance(self.f, str)
f = self.f
if not isinstance(f, str):
return None
Copy link
Member

Choose a reason for hiding this comment

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

Not necessarily opposed, but why this change? My original thinking was to have each method determine whether or not it would take action rather than the caller - this way that logic is easily shared between the subclasses.

Copy link
Member Author

Choose a reason for hiding this comment

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

when going through these and seeing

result = self.foo()
if result is not None:
    return result

[...]

it isnt obvious what cases lead to result = None. e.g. before i checked, i imagined it could have been something like

def foo(self):
    try:
        [...]
    except Bar:
        return None

Copy link
Member

Choose a reason for hiding this comment

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

I see. Looking at this now, I see my usage of maybe_* is a bit different than other places in code, where maybe an operation is applied to data but the data is always returned regardless. The downside is that the condition then needs repeated, but it is simple enough (at least at this point) that I don't find that concerning at all.

Copy link
Member

Choose a reason for hiding this comment

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

I think this change should be applied to maybe_apply_multiple, and the maybe prefix should be dropped. I'm happy to take care of those in a followup.

Comment on lines +467 to -479
# Caller is responsible for checking isinstance(self.f, str)
f = self.f
if not isinstance(f, str):
return None
Copy link
Member

Choose a reason for hiding this comment

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

I see. Looking at this now, I see my usage of maybe_* is a bit different than other places in code, where maybe an operation is applied to data but the data is always returned regardless. The downside is that the condition then needs repeated, but it is simple enough (at least at this point) that I don't find that concerning at all.

Comment on lines +467 to -479
# Caller is responsible for checking isinstance(self.f, str)
f = self.f
if not isinstance(f, str):
return None
Copy link
Member

Choose a reason for hiding this comment

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

I think this change should be applied to maybe_apply_multiple, and the maybe prefix should be dropped. I'm happy to take care of those in a followup.

@jbrockmendel
Copy link
Member Author

gentle ping; there's more id like to get to in this area

@jreback jreback merged commit adb3202 into pandas-dev:master Apr 28, 2021
@jbrockmendel jbrockmendel deleted the ref-apply branch April 28, 2021 15:53
yeshsurya pushed a commit to yeshsurya/pandas that referenced this pull request May 6, 2021
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform, Map Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants