We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In [386]: h = pd.DataFrame({'a':[1,2,1,np.nan,1], 'b':[1,2,3,3,2], 'c':[2,3,1,4,2]}) In [387]: gh=h.groupby(['a', 'b']) In [388]: gh.groups.keys() Out[388]: [(1.0, 2), (nan, 3), (1.0, 3), (1.0, 1), (2.0, 2)] In [389]: gh.indices.keys() Out[389]: [(1.0, 2), (1.0, 3), (2.0, 3), (1.0, 1), (2.0, 2)] # Incorrect
The tuple (2.0, 3) should not be here. The problem goes away when there are no NAs
The text was updated successfully, but these errors were encountered:
pandas.core.groupby:_get_indices_dict seems causing the problem.
pandas.core.groupby:_get_indices_dict
In [61]: label_list = [ping.labels for ping in gh.grouper.groupings] In [76]: keys = [_values_from_object(ping.group_index) for ping in gh.grouper.groupings] In [77]: keys Out[77]: [array([ 1., 2.]), array([1, 2, 3])] In [78]: label_list Out[78]: [array([ 0, 1, 0, -1, 0]), array([0, 1, 2, 2, 1])] In [79]: _get_indices_dict(label_list, keys) Out[79]: {(1.0, 2): array([4]), (1.0, 3): array([2]), (2.0, 3): array([3]), (1.0, 1): array([0]), (2.0, 2): array([1])}
Sorry, something went wrong.
groupbying with a nan group (or in a level) is not really supported. In general these cause weird types of issues. I'll mark it as a bug though.
nan
rhshadrach
Successfully merging a pull request may close this issue.
The tuple (2.0, 3) should not be here.
The problem goes away when there are no NAs
The text was updated successfully, but these errors were encountered: