Skip to content

TST: groupby-reindex on DTI #33638

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

Conversation

CloseChoice
Copy link
Member

@CloseChoice CloseChoice commented Apr 18, 2020

Add test to check whether reindexing works correctly.

@WillAyd
Copy link
Member

WillAyd commented Apr 19, 2020

I think need to run black on the change to get CI to pass

@WillAyd WillAyd added the Testing pandas testing functions or related to the test suite label Apr 19, 2020
@CloseChoice CloseChoice force-pushed the test-for-former-apply-reindex-bug branch from 4ba0e25 to 256a584 Compare April 20, 2020 19:37
@CloseChoice CloseChoice force-pushed the test-for-former-apply-reindex-bug branch from 256a584 to 8846135 Compare April 20, 2020 19:49
@CloseChoice
Copy link
Member Author

I think need to run black on the change to get CI to pass

done and now CI-linting passes

srs_exp = pd.Series(values, index=indices, name="value")
srs_grouped = df.groupby("group").value.apply(
lambda x: x.reindex(np.arange(x.index.min(), x.index.max() + 1))
)
Copy link
Member

Choose a reason for hiding this comment

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

theres a lot going on here. can you break this up into multiple lines and comment on which one used to be a problem

Copy link
Member Author

Choose a reason for hiding this comment

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

I wrote a seperate apply function and gave a little bit more background in the comments. Let me know if there is still somthing missing

srs_grouped = df.groupby("group").value.apply(
lambda x: x.reindex(np.arange(x.index.min(), x.index.max() + 1))
)
tm.assert_series_equal(srs_exp, srs_grouped)
Copy link
Member

Choose a reason for hiding this comment

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

can you call these expected and result

Copy link
Member Author

Choose a reason for hiding this comment

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

done



def test_apply_reindex_values():
# GH: 26209
Copy link
Member

Choose a reason for hiding this comment

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

a few words about what the bug was would be hepful

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@pep8speaks
Copy link

pep8speaks commented Apr 23, 2020

Hello @CloseChoice! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-04-23 22:17:39 UTC

@jreback jreback added Groupby Datetime Datetime data dtype labels Apr 25, 2020
@jreback jreback added this to the 1.1 milestone Apr 25, 2020
@jreback jreback changed the title add test for former bug (appeared in 0.24.2 but fixed in further version TST: groupby-reindex on DTI Apr 25, 2020
@jreback jreback merged commit 23e91a7 into pandas-dev:master Apr 25, 2020
@jreback
Copy link
Contributor

jreback commented Apr 25, 2020

thanks @CloseChoice

rhshadrach pushed a commit to rhshadrach/pandas that referenced this pull request May 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Groupby Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reindex does not work for groupby series with DateTimeIndex
6 participants