Skip to content
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

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

Closed
jreback opened this issue May 8, 2015 · 1 comment
Closed
Labels
Bug Duplicate Report Duplicate issue or pull request Groupby Resample resample method

Comments

@jreback
Copy link
Contributor

jreback commented May 8, 2015

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
@jreback jreback added Bug Groupby Resample resample method labels May 8, 2015
@jreback jreback added this to the 0.17.0 milestone May 8, 2015
@jreback jreback modified the milestones: Next Major Release, 0.17.0 Aug 15, 2015
@jreback
Copy link
Contributor Author

jreback commented Oct 8, 2017

this is a duplicate of #17530 and closed by #17587

@jreback jreback closed this as completed Oct 8, 2017
@jreback jreback added the Duplicate Report Duplicate issue or pull request label Oct 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Duplicate Report Duplicate issue or pull request Groupby Resample resample method
Projects
None yet
Development

No branches or pull requests

1 participant