Skip to content
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

Fix Up Typing in GroupBy #26089

Merged
merged 8 commits into from Apr 17, 2019

Conversation

@WillAyd
Copy link
Member

commented Apr 14, 2019

More typing cleanups

Original failures:

pandas/core/groupby/ops.py:13: error: Module 'pandas._libs' has no attribute 'groupby'
pandas/core/groupby/ops.py:13: error: Module 'pandas._libs' has no attribute 'reduction'
pandas/core/groupby/groupby.py:22: error: Module 'pandas._libs' has no attribute 'groupby'
pandas/core/groupby/groupby.py:329: error: Need type annotation for '_apply_whitelist'
pandas/core/groupby/generic.py:220: error: Incompatible types in assignment (expression has type "Callable[[Arg(Any, 'arg'), VarArg(Any), KwArg(Any)], Any]", base class "SelectionMixin" defined the type as "Callable[[Arg(Any, 'func'), VarArg(Any), KwArg(Any)], Any]")

@WillAyd WillAyd added the Typing label Apr 14, 2019

@@ -179,25 +179,25 @@ def _post_process_cython_aggregate(self, obj):
obj = obj.swapaxes(0, 1)
return obj

def aggregate(self, arg, *args, **kwargs):
def aggregate(self, func, *args, **kwargs):

This comment has been minimized.

Copy link
@WillAyd

WillAyd Apr 14, 2019

Author Member

The reason for this change is that MyPy was complaining about the signature here differening from what's defined in SelectionMixin. This aligns the signatures and is arguably more readable.

Counter argument is that this is an API change, but this actually would match the docs

image

This comment has been minimized.

Copy link
@jreback

jreback Apr 15, 2019

Contributor

this is ok, pls add a note in the whatsnew about this though

@codecov

This comment has been minimized.

Copy link

commented Apr 15, 2019

Codecov Report

Merging #26089 into master will decrease coverage by 51.2%.
The diff coverage is 72.72%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #26089       +/-   ##
===========================================
- Coverage   91.96%   40.75%   -51.21%     
===========================================
  Files         175      175               
  Lines       52412    52447       +35     
===========================================
- Hits        48200    21376    -26824     
- Misses       4212    31071    +26859
Flag Coverage Δ
#multiple ?
#single 40.75% <72.72%> (-0.12%) ⬇️
Impacted Files Coverage Δ
pandas/core/groupby/groupby.py 24.59% <100%> (-72.63%) ⬇️
pandas/core/groupby/ops.py 20.04% <100%> (-74.17%) ⬇️
pandas/core/groupby/generic.py 13.3% <25%> (-73.79%) ⬇️
pandas/io/formats/latex.py 0% <0%> (-100%) ⬇️
pandas/io/sas/sas_constants.py 0% <0%> (-100%) ⬇️
pandas/core/groupby/categorical.py 0% <0%> (-100%) ⬇️
pandas/tseries/plotting.py 0% <0%> (-100%) ⬇️
pandas/tseries/converter.py 0% <0%> (-100%) ⬇️
pandas/io/formats/html.py 0% <0%> (-99.37%) ⬇️
pandas/io/sas/sas7bdat.py 0% <0%> (-91.16%) ⬇️
... and 136 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7b3bf2d...00ea674. Read the comment docs.

@codecov

This comment has been minimized.

Copy link

commented Apr 15, 2019

Codecov Report

Merging #26089 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26089      +/-   ##
==========================================
- Coverage   91.99%   91.98%   -0.01%     
==========================================
  Files         175      175              
  Lines       52384    52387       +3     
==========================================
- Hits        48189    48187       -2     
- Misses       4195     4200       +5
Flag Coverage Δ
#multiple 90.53% <100%> (ø) ⬆️
#single 40.74% <72.72%> (-0.13%) ⬇️
Impacted Files Coverage Δ
pandas/core/groupby/groupby.py 97.23% <100%> (ø) ⬆️
pandas/core/groupby/generic.py 89.02% <100%> (ø) ⬆️
pandas/core/groupby/ops.py 94.23% <100%> (+0.02%) ⬆️
pandas/io/gbq.py 75% <0%> (-12.5%) ⬇️
pandas/core/frame.py 96.9% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.61% <0%> (-0.11%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b60ebb...162efaa. Read the comment docs.

@WillAyd WillAyd added this to the 0.25.0 milestone Apr 15, 2019

@jreback
Copy link
Contributor

left a comment

merge master as well

@@ -218,6 +218,7 @@ Other API Changes
- :meth:`Timestamp.strptime` will now rise a ``NotImplementedError`` (:issue:`25016`)
- Comparing :class:`Timestamp` with unsupported objects now returns :py:obj:`NotImplemented` instead of raising ``TypeError``. This implies that unsupported rich comparisons are delegated to the other object, and are now consistent with Python 3 behavior for ``datetime`` objects (:issue:`24011`)
- Bug in :meth:`DatetimeIndex.snap` which didn't preserving the ``name`` of the input :class:`Index` (:issue:`25575`)
- The ``arg`` argument in :meth:`pandas.core.groupby.DataFrameGroupBy.agg` has been renamed to ``func`` to match the signature of its superclass (:issue:`26089`)

This comment has been minimized.

Copy link
@jreback

jreback Apr 16, 2019

Contributor

I would remove the work superclass; this is unknown to the user

@jreback jreback merged commit 06843a8 into pandas-dev:master Apr 17, 2019

11 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
pandas-dev.pandas Build #20190417.24 succeeded
Details
pandas-dev.pandas (Checks_and_doc) Checks_and_doc succeeded
Details
pandas-dev.pandas (Linux py35_compat) Linux py35_compat succeeded
Details
pandas-dev.pandas (Linux py36_locale_slow) Linux py36_locale_slow succeeded
Details
pandas-dev.pandas (Linux py36_locale_slow_old_np) Linux py36_locale_slow_old_np succeeded
Details
pandas-dev.pandas (Linux py37_locale) Linux py37_locale succeeded
Details
pandas-dev.pandas (Linux py37_np_dev) Linux py37_np_dev succeeded
Details
pandas-dev.pandas (Windows py36_np15) Windows py36_np15 succeeded
Details
pandas-dev.pandas (Windows py37_np141) Windows py37_np141 succeeded
Details
pandas-dev.pandas (macOS py35_macos) macOS py35_macos succeeded
Details
@jreback

This comment has been minimized.

Copy link
Contributor

commented Apr 17, 2019

thanks @WillAyd

yhaque1213 added a commit to yhaque1213/pandas that referenced this pull request Apr 22, 2019

@gwrome gwrome referenced this pull request May 2, 2019

Closed

Typing Cleanup - Remove Blacklisted Items #25882

64 of 65 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.