-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: corrwith and tshift in groupby/groupby.transform #32069
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
TST: corrwith and tshift in groupby/groupby.transform #32069
Conversation
254ffdf
to
b8c622d
Compare
@ryankarlos is there more to add. if not I don't think this closes the issue? |
@simonjayhawkins yes Im thinking of adding for |
those are explicitly mentioned in the issue, so could add here or seperate PRs and change the OP of this PR to xref instead of closes.
not sure. @charlesdong1991 ? |
So there is already a fixture called |
Thanlks @WillAyd , Ive now added new tests with the |
fdb5566
to
179046b
Compare
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.
@ryankarlos there is a test, test_transform_transformation_func on L321 that was added recently. Should these be included there or at least co-located with that test?
looking at pandas/pandas/tests/groupby/test_transform.py Lines 330 to 332 in 53ece70
it appears that pad and cumcount need to be tested also. |
So these other functions were throwing |
0dfe209
to
4d0fa2a
Compare
g = df.groupby("A") | ||
|
||
op = lambda x: getattr(x, "corrwith")(df) | ||
result = op(g) |
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 is g.corrwith(df)
.
should we be testing g.transform("corrwith", df)
to address #27905? (which raises AttributeError: 'Series' object has no attribute 'corrwith')
g.corrwith(df) is tested in pandas\tests\groupby\test_groupby.py
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.
so the only instance using corrwith
in test_groupby.py
is in test_dup_labels_output_shape
which doesn't seem to be fully testing the output of corrwith
as is done here
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
def test_groupby_tshift(df_for_transformation_func): |
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.
should this test be testing g.transform("tshift", ...)
?
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.
The output of g.transform("tshift", ...)
seems to be buggy - ive just raised an issue #32344. Ive added a case for this and marked as pytest.xfail
for now.
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.
A quick glance, it appears that with the latest changes, the tests are now not testing for expected behavior, since there are bugs that need to be fixed first. Is that correct @charlesdong1991 ?
@simonjayhawkins to be honest, think this original issue may be out of date and superseded by #32293 , #31269 , #27472 and #32344 reporting the associated bugs which need to be fixed first for If you want I could just leave the tests for |
Thanks @ryankarlos for the work here, much appreciated, but I'll close this PR and close the issue too. |
This PR tests
corrwith
andtshift
, so not sure if it fully closes the original issue or not, but the other functionsbackfill
,pad
andcumcount
don't seem to be supported ingroupby.transform
as reported in issues #27472 and #31269.black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff