-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: annotations in core.apply #29477
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
Conversation
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.
@jbrockmendel generally lgtm. a few comments.
pandas/core/apply.py
Outdated
|
||
@property | ||
def axis(self) -> int: | ||
raise AbstractMethodError(self) |
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.
can we not use @abc.abstractmethod going forward for new code?
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.
OK. It looks like for axis I can do just axis: int
but for the others I have to use property+abc.abstractmethod.
Updated.
|
||
def __init__( | ||
self, | ||
obj: "DataFrame", |
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.
should we consider making FrameApply generic if we want subclassed DataFrames to return same type?
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.
im not sure i understand the question. FrameApply is the base class for ColumnFrameApply and RowFrameApply
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've not looked in detail but may not be relevant here.
Not sure how geopandas (or other downstream packages work), Just keeping in mind that, say GeoDataFrame, may return a GeoDataFrame with certain operations.
did start to type geopandas so I had a better idea, see geopandas/geopandas@master...simonjayhawkins:typing.
Note to self: Should try and get back to this.
raise AbstractMethodError(self) | ||
|
||
@property | ||
def series_generator(self) -> Iterator["Series"]: |
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.
For return types, this could also be typed as Iterable
. we've done this in a couple of places.
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.
isnt iterator more informative than iterable?
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.
for a return type it's nor relevant, so it's just a consistency thing.
updated the abstractmethod thing. didnt change Iterator-> Iterable because i still have a mild preference, but will if its a deal-breaker. |
cool |
make
apply_broadcast
have consistent signature.After this I plan to do a pass to make these classes much less stateful