-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC/TYP: Fixed typing and doc #33374
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
DOC/TYP: Fixed typing and doc #33374
Conversation
pandas/core/aggregation.py
Outdated
def normalize_keyword_aggregation(kwargs: dict) -> Tuple[dict, List[str], List[int]]: | ||
def normalize_keyword_aggregation( | ||
kwargs: dict, | ||
) -> Tuple[DefaultDict, Tuple[Hashable, ...], "np.ndarray"]: |
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.
What issue is this fixing?
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.
see #33263 (comment)
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.
@MomIsBestFriend can you git bisect or blame to find out what's the story behind the change 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.
@simonjayhawkins It looks like no one can agree on the placement of this function, as it's moved around constantly.
But it looks like parts of the changes are made in #30497 while migrating from orderedict
to defaultdict
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.
normalize_keyword_aggregation is only called by aggregate in core\groupby\generic.py.
the core\groupby\generic.py module is currently excluded by check_untyped_defs and aggregate does not have type hints.
maybe worth typing aggregate as well to ensure consistency.
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.
@simonjayhawkins Nice! thanks to that tip I could annotate with much more specific type hints.
pandas/core/aggregation.py
Outdated
@@ -40,7 +43,9 @@ def is_multi_agg_with_relabel(**kwargs) -> bool: | |||
) | |||
|
|||
|
|||
def normalize_keyword_aggregation(kwargs: dict) -> Tuple[dict, List[str], List[int]]: | |||
def normalize_keyword_aggregation( | |||
kwargs: dict, |
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 should be Dict from typing. can you see if you can also add type parameters to Dict.
@@ -909,7 +911,9 @@ class DataFrameGroupBy(GroupBy[DataFrame]): | |||
axis="", | |||
) | |||
@Appender(_shared_docs["aggregate"]) | |||
def aggregate(self, func=None, *args, **kwargs): | |||
def aggregate( | |||
self, func: Optional[DefaultDict[str, List[Scalar]]] = None, *args, **kwargs |
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 can also be a list / dict of callables no?
@MomIsBestFriend can you rebase (and address any actionable comments) |
Thanks @MomIsBestFriend closing as stale. ping to reopen. |
pandas/core/aggregation.py
#33263 (review)black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff