Skip to content

ENH: resample - upsampling on level #16267

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

Open
jreback opened this issue May 6, 2017 · 0 comments
Open

ENH: resample - upsampling on level #16267

jreback opened this issue May 6, 2017 · 0 comments

Comments

@jreback
Copy link
Contributor

jreback commented May 6, 2017

example from #7895

In [39]: d1 = Index(pd.date_range('1/1/2012', '3/1/2012', freq='MS'), name='date')
    ...: df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}, index=d1)
    ...: df.columns.names=['id']
    ...: s = df.unstack()
    ...: s.name = 'value'
    ...: 

In [40]: s
Out[40]: 
id  date      
A   2012-01-01    1
    2012-02-01    2
    2012-03-01    3
B   2012-01-01    4
    2012-02-01    5
    2012-03-01    6
Name: value, dtype: int64

In [41]: s.resample('D', level='date').asfreq()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-41-810faaa64080> in <module>()
----> 1 s.resample('D', level='date').asfreq()

/Users/jreback/pandas/pandas/core/resample.py in asfreq(self, fill_value)
    518         DataFrame.asfreq
    519         """
--> 520         return self._upsample('asfreq', fill_value=fill_value)
    521 
    522     def std(self, ddof=1, *args, **kwargs):

/Users/jreback/pandas/pandas/core/resample.py in _upsample(self, method, limit, fill_value)
    737             raise AssertionError('axis must be 0')
    738         if self._from_selection:
--> 739             raise ValueError("Upsampling from level= or on= selection"
    740                              " is not supported, use .set_index(...)"
    741                              " to explicitly set index to"

ValueError: Upsampling from level= or on= selection is not supported, use .set_index(...) to explicitly set index to datetime-like

This is like #7895 in that we are reindexing on a level (generated via resample). So it equivalent in this case.

This should work.

@jreback jreback added this to the Next Minor Release milestone May 6, 2017
@jreback jreback modified the milestones: Interesting Issues, Next Major Release Nov 26, 2017
@mroeschke mroeschke removed this from the Contributions Welcome milestone Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants