Skip to content

BUG: partial nan levels missing when grouping #10484

Closed
@jreback

Description

@jreback

from #10468

In [40]: df = DataFrame({'A' : [1,2,3]},index=pd.MultiIndex.from_tuples([(1,np.nan),(1,1),(2,1)],names=['first','second']))

In [41]: df
Out[41]: 
              A
first second   
1     NaN     1
      1       2
2     1       3

In [42]: df.groupby(level='second').sum()
Out[42]: 
        A
second   
1       5

In [43]: df.groupby(level=['first','second']).sum()
Out[43]: 
              A
first second   
1     1       2
2     1       3

I suppose that [43] is missing the (1,nan) group here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugGroupbyMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions