pandas-vet icon indicating copy to clipboard operation
pandas-vet copied to clipboard

Implement check for groupby slicing and aggregation patterns.

Open simchuck opened this issue 5 years ago • 2 comments

Pending determination of acceptable use cases for this pattern, this PR checks for explicit use of the following patterns with explicit slicing syntax on the groupby() method:

df.groupby(A)[B]          # for ast.Subscript nodes
df.groupby(A)[B].agg(C)   # for ast.Call nodes

Note that this requires two separate check functions due to above distinction in AST. Also, includes check to distinguish between method (node.func.attr) vs. function (node.func.id).

The implementation does not check syntax for functions, although commented tests are included in test_PD014.py in case this is determined to be acceptable syntax for check.

Closes #24 (pending)

simchuck avatar Mar 11 '19 19:03 simchuck

@simchuck, any interest in revisiting this? Once the off-by-default framework (#69) is merged, I think this would be a good PD902. It is probably too opinionated for most everyday pandas applications.

Let me know if you want to take it on. If not, I'll give it a shot.

deppen8 avatar Aug 04 '19 19:08 deppen8

I'll have a look.

On Sun, Aug 4, 2019 at 12:37 PM Jacob Deppen [email protected] wrote:

@simchuck https://github.com/simchuck, any interest in revisiting this? Once the off-by-default framework (#69 https://github.com/deppen8/pandas-vet/pull/69) is merged, I think this would be a good PD902. It is probably too opinionated for most everyday pandas applications.

Let me know if you want to take it on. If not, I'll give it a shot.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/deppen8/pandas-vet/pull/54?email_source=notifications&email_token=AAO2YGRX7DSIE6U7KWMXE3TQC4VWVA5CNFSM4G5FWRMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3QIHGI#issuecomment-518030233, or mute the thread https://github.com/notifications/unsubscribe-auth/AAO2YGVN2DHER3VYGEP4ROLQC4VWVANCNFSM4G5FWRMA .

simchuck avatar Aug 07 '19 05:08 simchuck