Skip to content

DOC: groupby by indexer to 'resample' data #13271

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

Closed
tomchor opened this issue May 24, 2016 · 7 comments · Fixed by #13276
Closed

DOC: groupby by indexer to 'resample' data #13271

tomchor opened this issue May 24, 2016 · 7 comments · Fixed by #13276

Comments

@tomchor
Copy link

tomchor commented May 24, 2016

Related to this question.

I would like to propose either to expand .resample to work on indexes that are integers or to create another method that does the same thing (maybe more general .upsample and .downsample methods).

If it was implemented as an expansion of resample I imagine something like:

df = pd.DataFrame(np.random.randn(10,2))
df.resample(5, np.std)

Which would produce:

          0         1
0  1.184582  0.492113
5  0.533134  0.982562

which is a pretty forward downsample case. For upsampling maybe some discussion is needed on how to return the indexes.

This should be simple to program and I think it would be a very useful shortcut.

@jreback
Copy link
Contributor

jreback commented May 24, 2016

You mean like this?

In [6]: df.groupby(df.index / 5).std()
Out[6]: 
          0         1
0  0.324344  0.824444
1  1.088061  0.854456

@jreback
Copy link
Contributor

jreback commented May 24, 2016

So'll rerpupose this to be a doc issue, if you'd like to add an example to: http://pandas.pydata.org/pandas-docs/stable/groupby.html#examples

@jreback jreback added this to the Next Major Release milestone May 24, 2016
@jreback jreback changed the title Expand resample method to work on indexes that aren't DatetimeIndex DOC: groupby by indexer to 'resample' data May 24, 2016
@tomchor
Copy link
Author

tomchor commented May 24, 2016

Yes, that is exactly what I meant! Nobody in SO that saw the question (including me) could come up with that.

I'm new to github, but I'll look up how to contribute and I'll probably write an example of that.

Thanks a lot.

@jreback
Copy link
Contributor

jreback commented May 24, 2016

contributing docs are here

thanks!

@pfrcks
Copy link
Contributor

pfrcks commented May 24, 2016

@jreback Hi, I was working on this and have implemented the requirement. However while doing so
I utilized
python make.py clean
python make.py --no-api

Followed by

python make.py --single groupby
As the example was added to groupby.
The contribution guide says "you must make sure not to commit the file deletions to your Git repository!"

Currently upon executing git status, it shows all of the rst files it deleted. I am unsure what to do now. Should I simply remove those deleted rst files being tracked or something else?

Thanks.

@jreback
Copy link
Contributor

jreback commented May 24, 2016

just commit that single file
the git stash to remove the other changes

@pfrcks
Copy link
Contributor

pfrcks commented May 25, 2016

Have added the example. Please take a look.

@jorisvandenbossche jorisvandenbossche modified the milestones: 0.18.2, Next Major Release Jun 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants