Skip to content

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

Closed

Conversation

ShaharNaveh
Copy link
Member

def normalize_keyword_aggregation(kwargs: dict) -> Tuple[dict, List[str], List[int]]:
def normalize_keyword_aggregation(
kwargs: dict,
) -> Tuple[DefaultDict, Tuple[Hashable, ...], "np.ndarray"]:
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@simonjayhawkins simonjayhawkins Apr 7, 2020

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.

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member Author

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.

@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Apr 7, 2020
@@ -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,
Copy link
Member

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
Copy link
Contributor

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?

@jbrockmendel
Copy link
Member

@MomIsBestFriend can you rebase (and address any actionable comments)

@simonjayhawkins
Copy link
Member

Thanks @MomIsBestFriend closing as stale. ping to reopen.

@ShaharNaveh ShaharNaveh deleted the DOC/TYP-Fix-core-aggregation branch May 3, 2021 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants