-
-
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
Changes from 1 commit
f5c9815
f944d39
1ca7ebb
bebe4b7
df9eb62
07fe310
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,16 @@ | |
|
||
from collections import defaultdict | ||
from functools import partial | ||
from typing import Any, DefaultDict, List, Sequence, Tuple | ||
from typing import TYPE_CHECKING, Any, DefaultDict, Hashable, Sequence, Tuple | ||
|
||
from pandas.core.dtypes.common import is_dict_like, is_list_like | ||
|
||
import pandas.core.common as com | ||
from pandas.core.indexes.api import Index | ||
|
||
if TYPE_CHECKING: | ||
import numpy as np # noqa: F401 | ||
|
||
|
||
def is_multi_agg_with_relabel(**kwargs) -> bool: | ||
""" | ||
|
@@ -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, | ||
) -> Tuple[DefaultDict, Tuple[Hashable, ...], "np.ndarray"]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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. |
||
""" | ||
Normalize user-provided "named aggregation" kwargs. | ||
Transforms from the new ``Mapping[str, NamedAgg]`` style kwargs | ||
|
@@ -52,11 +57,11 @@ def normalize_keyword_aggregation(kwargs: dict) -> Tuple[dict, List[str], List[i | |
|
||
Returns | ||
------- | ||
aggspec : dict | ||
aggspec : collections.defaultdict of lists | ||
The transformed kwargs. | ||
columns : List[str] | ||
columns : tuple | ||
The user-provided keys. | ||
col_idx_order : List[int] | ||
col_idx_order : numpy.ndarray | ||
List of columns indices. | ||
|
||
Examples | ||
|
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.