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

ohlc not available for groupby/etc #6594

Closed
hayd opened this issue Mar 11, 2014 · 8 comments
Closed

ohlc not available for groupby/etc #6594

hayd opened this issue Mar 11, 2014 · 8 comments
Labels
Error Reporting Incorrect or improved errors from pandas Groupby Resample resample method Testing pandas testing functions or related to the test suite
Milestone

Comments

@hayd
Copy link
Contributor

hayd commented Mar 11, 2014

Was this available at some stage (it's looking in self._cython_functions for it rather than just saying no dice with a plain ol' AttributeError):

In [1]: rng = pd.date_range('2012', periods=3)

In [2]: df = pd.DataFrame([[1, 2], [1, 3], [5, 6]], rng, columns=['A', 'B'])

In [3]: g = df.groupby('A')

In [4]: g.foo()
AttributeError: 'DataFrameGroupBy' object has no attribute 'foo'

In [5]: g.ohlc()
KeyError: 'ohlc'

In [6]: g.ohlc(rule='D')
TypeError: ohlc() got an unexpected keyword argument 'rule'

Can do atm using g.resample('D', how='ohlc').

@jreback
Copy link
Contributor

jreback commented Mar 11, 2014

hmm

I think this is only valid as a resample method

@hayd
Copy link
Contributor Author

hayd commented Mar 11, 2014

close or leave open? (Do we want a sep method... someday ? - not sure it's needed tbh)

I added the resample version to sub-selection tests, so we're good on that front.

@jreback
Copy link
Contributor

jreback commented Mar 11, 2014

I would blacklist it to get the correct error message
but might break resample

@jreback jreback added this to the 0.14.0 milestone Mar 22, 2014
@jreback
Copy link
Contributor

jreback commented Mar 22, 2014

I think this should have a better error message

@hayd
Copy link
Contributor Author

hayd commented Mar 24, 2014

We could just create the method and raise saying to use resample(how="ohlc")... or better yet just do the resample?

@jreback
Copy link
Contributor

jreback commented Mar 24, 2014

I don't think you should do the resample, but raising a more helpful message is good.

@jreback jreback modified the milestones: 0.15.0, 0.14.0 Apr 9, 2014
@jreback jreback modified the milestones: 0.14.0, 0.15.0 Apr 29, 2014
@jreback jreback modified the milestones: 0.15.0, 0.14.0 Apr 29, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 3, 2015
@jreback
Copy link
Contributor

jreback commented Feb 17, 2016

this totally works now (need slight change to syntax as the above is not valid), needing testing/validation

In [31]: df.groupby(pd.Grouper(freq='D')).ohlc()
Out[31]: 
              A                   B               
           open high low close open high low close
2012-01-01    1    1   1     1    2    2   2     2
2012-01-02    1    1   1     1    3    3   3     3
2012-01-03    5    5   5     5    6    6   6     6
In [33]: df.groupby('A').ohlc()
Out[33]: 
     A                   B               
  open high low close open high low close
A                                        
1    1    1   1     1    2    3   2     3
5    5    5   5     5    6    6   6     6

@jreback jreback added Testing pandas testing functions or related to the test suite Difficulty Novice Resample resample method labels Feb 17, 2016
@jreback jreback modified the milestones: 0.18.1, Next Major Release Feb 17, 2016
@jreback
Copy link
Contributor

jreback commented Apr 18, 2016

closing as this is already supported with a timegrouper / resample.

@jreback jreback closed this as completed Apr 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas Groupby Resample resample method Testing pandas testing functions or related to the test suite
Projects
None yet
Development

No branches or pull requests

2 participants