Skip to content

Bug resampling quarterly period data to annual #1622

@wesm

Description

@wesm
In [10]: rng = period_range('2000Q1', periods=10, freq='Q-DEC')

In [11]: rng
Out[11]: 
<class 'pandas.tseries.period.PeriodIndex'>
freq: Q-DEC
[2000Q1, ..., 2002Q2]
length: 10

In [12]: ts = Series(np.arange(10), index=rng)

In [13]: ts
Out[13]: 
2000Q1    0
2000Q2    1
2000Q3    2
2000Q4    3
2001Q1    4
2001Q2    5
2001Q3    6
2001Q4    7
2002Q1    8
2002Q2    9
Freq: Q-DEC

In [14]: ts.resample('A')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/wesm/Dropbox/talks/scipy2012/tutorial/<ipython-input-14-d20eb06885e9> in <module>()
----> 1 ts.resample('A')

/home/wesm/code/pandas/pandas/core/generic.pyc in resample(self, rule, how, axis, fill_method, closed, label, convention, kind, loffset, limit, base)
    187                               fill_method=fill_method, convention=convention,
    188                               limit=limit, base=base)
--> 189         return sampler.resample(self)
    190 
    191     def first(self, offset):

/home/wesm/code/pandas/pandas/tseries/resample.pyc in resample(self, obj)
     72 
     73             if self.kind is None or self.kind == 'period':
---> 74                 return self._resample_periods(obj)
     75             else:
     76                 obj = obj.to_timestamp(how=self.convention)

/home/wesm/code/pandas/pandas/tseries/resample.pyc in _resample_periods(self, obj)
    233         else:
    234             raise ValueError('Frequency %s cannot be resampled to %s'
--> 235                              % (axlabels.freq, self.freq))
    236 
    237 

ValueError: Frequency Q-DEC cannot be resampled to <1 YearEnd: kwds={'month': 12}, month=12>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions