Skip to content

BUG: value_counts can handle the case even with empty groups (#28479) #28634

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 31 commits into from
Nov 7, 2019

Conversation

dongho-jung
Copy link
Contributor

  • If applying rep to recons_labels go fail, use ids which has no
    consecutive duplicates instead.

xuancong84 found that value_counts() crashes if groupby object contains empty groups.
However, even though I made the construction of DataFrame don't skip empty rows, it still crashed.
Till then, I already tried in many ways though, in this time I tried to correct the callee self.grouper.recons_labels. After several tests, I found that If freq of Grouper is too long so that it has empty groups in some periods then it crashes. And also have found that this is solved by using ids which has no consecutive duplicates instead of self.grouper.recons_labels.

…dev#28479)

    * If applying rep to recons_labels go fail, use ids which has no
      consecutive duplicates instead.
@dongho-jung
Copy link
Contributor Author

Sorry for the second commit... Can it be squashed..?

@jreback
Copy link
Contributor

jreback commented Sep 26, 2019

@0xF4D3C0D3 FYI you don't need to create a new PR, you can simply rebase and push to the existing one (leave this as its already done)

@dongho-jung
Copy link
Contributor Author

@jreback Thanks for your advice, I just worried that if I had committed something like a trivial typo, it would have made the history of main repo dirty. So for the sake of only one commit, I checkout with another branch and commit with a random message and git reset --soft HEAD~2 and git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})" for squashing. You mean that I don't need all this fuss and it's ok that PR with multiple commits as it can be squashed when it merged?

@jreback
Copy link
Contributor

jreback commented Sep 26, 2019

You mean that I don't need all this fuss and it's ok that PR with multiple commits as it can be squashed when it merged?

yes you can do whatever you want, including merges & rebases on a branch; on merge we will squash to a single commit.

@dongho-jung
Copy link
Contributor Author

Wow, that's cool! sorry for my inexperience D:
I'll practice and learn more to better contribution. Thanks

@dongho-jung dongho-jung requested a review from jreback October 17, 2019 03:00
1. remove the seed
2. remove meaningless comment
3. refer to GH issue number
@dongho-jung dongho-jung requested a review from jreback October 31, 2019 02:25
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

are there any perf implications here? e.g. show the run of the groupby asvs

@dongho-jung dongho-jung requested a review from jreback November 6, 2019 01:38
@jreback jreback added this to the 1.0 milestone Nov 6, 2019
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm. pls merge master and ping on green.

@dongho-jung dongho-jung requested a review from WillAyd November 7, 2019 13:51
@jreback jreback merged commit 8efc717 into pandas-dev:master Nov 7, 2019
@jreback
Copy link
Contributor

jreback commented Nov 7, 2019

thanks @0xF4D3C0D3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

value_counts() crashes if groupby object contains empty groups
5 participants