Skip to content

TYP: misc cleanup in core\groupby\generic.py #35955

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
Aug 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import copy
from functools import partial
from textwrap import dedent
import typing
from typing import (
TYPE_CHECKING,
Any,
Expand All @@ -22,6 +21,7 @@
Optional,
Sequence,
Type,
TypeVar,
Union,
)
import warnings
Expand Down Expand Up @@ -92,7 +92,7 @@
# TODO: validate types on ScalarResult and move to _typing
# Blocked from using by https://github.com/python/mypy/issues/1484
# See note at _mangle_lambda_list
ScalarResult = typing.TypeVar("ScalarResult")
ScalarResult = TypeVar("ScalarResult")


def generate_property(name: str, klass: Type[FrameOrSeries]):
Expand Down Expand Up @@ -606,8 +606,8 @@ def filter(self, func, dropna=True, *args, **kwargs):
wrapper = lambda x: func(x, *args, **kwargs)

# Interpret np.nan as False.
def true_and_notna(x, *args, **kwargs) -> bool:
b = wrapper(x, *args, **kwargs)
def true_and_notna(x) -> bool:
b = wrapper(x)
return b and notna(b)

try:
Expand Down Expand Up @@ -1210,7 +1210,7 @@ def _wrap_applied_output(self, keys, values, not_indexed_same=False):
# TODO: Remove when default dtype of empty Series is object
kwargs = first_not_none._construct_axes_dict()
backup = create_series_with_explicit_dtype(
**kwargs, dtype_if_empty=object
dtype_if_empty=object, **kwargs
)

values = [x if (x is not None) else backup for x in values]
Expand Down