Skip to content

BUG: Timegrouping not mirroring resample when groupby is a list indexer #10084

Closed
@jreback

Description

@jreback

so it appears that [9] is wrong, should be consistent with [7],[8]

In [1]: index = date_range('20130101',freq='2D',periods=6)

In [2]: df = DataFrame(np.arange(20).reshape(5,4),columns=list('ABCD'),index=index.take([0,1,2,3,4]))

In [3]: df.resample('2D',how='max')
Out[3]: 
             A   B   C   D
2013-01-01   0   1   2   3
2013-01-03   4   5   6   7
2013-01-05   8   9  10  11
2013-01-07  12  13  14  15
2013-01-09  16  17  18  19

In [4]: df.groupby(pd.Grouper(level=0,freq='2D')).max()
Out[4]: 
             A   B   C   D
2013-01-01   0   1   2   3
2013-01-03   4   5   6   7
2013-01-05   8   9  10  11
2013-01-07  12  13  14  15
2013-01-09  16  17  18  19

In [5]: df.groupby([pd.Grouper(level=0,freq='2D')]).max()
Out[5]: 
             A   B   C   D
2013-01-01   0   1   2   3
2013-01-03   4   5   6   7
2013-01-05   8   9  10  11
2013-01-07  12  13  14  15
2013-01-09  16  17  18  19

In [6]: 

In [6]: df = DataFrame(np.arange(20).reshape(5,4),columns=list('ABCD'),index=index.take([0,1,2,4,5]))

In [7]: df.resample('2D')
Out[7]: 
             A   B   C   D
2013-01-01   0   1   2   3
2013-01-03   4   5   6   7
2013-01-05   8   9  10  11
2013-01-07 NaN NaN NaN NaN
2013-01-09  12  13  14  15
2013-01-11  16  17  18  19

In [8]: df.groupby(pd.Grouper(level=0,freq='2D')).max()
Out[8]: 
             A   B   C   D
2013-01-01   0   1   2   3
2013-01-03   4   5   6   7
2013-01-05   8   9  10  11
2013-01-07 NaN NaN NaN NaN
2013-01-09  12  13  14  15
2013-01-11  16  17  18  19

In [9]: df.groupby([pd.Grouper(level=0,freq='2D')]).max()
Out[9]: 
             A   B   C   D
2013-01-01   0   1   2   3
2013-01-03   4   5   6   7
2013-01-05   8   9  10  11
2013-01-09  12  13  14  15
2013-01-11  16  17  18  19

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions