-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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: Resampling a TZ-aware Series fails if rule='W': "Values falls before first bin" #9119
Comments
This may be fixed in #5172 or maybe not (those are specific DST issues, but I saw some things in general that might overall fix it). I will see if fixing those cases fixes this as well. |
I have just checked this issue on Pandas 0.16.1 and I can confirm that this issue is still present (which I think we knew, but I just wanted to confirm!) Although the line numbers in the exception have changed a bit: In [1]: import pandas as pd
In [2]: rng = pd.date_range("2013-04-01", "2013-05-01", tz='Europe/London', freq='H')
In [3]: series = pd.Series(index=rng)
In [4]: series.resample('W')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-906374246edd> in <module>()
----> 1 series.resample('W')
/usr/local/lib/python2.7/dist-packages/pandas/core/generic.pyc in resample(self, rule, how, axis, fill_method, closed, label, convention, kind, loffset, limit, base)
3195 fill_method=fill_method, convention=convention,
3196 limit=limit, base=base)
-> 3197 return sampler.resample(self).__finalize__(self)
3198
3199 def first(self, offset):
/usr/local/lib/python2.7/dist-packages/pandas/tseries/resample.pyc in resample(self, obj)
83
84 if isinstance(ax, DatetimeIndex):
---> 85 rs = self._resample_timestamps()
86 elif isinstance(ax, PeriodIndex):
87 offset = to_offset(self.freq)
/usr/local/lib/python2.7/dist-packages/pandas/tseries/resample.pyc in _resample_timestamps(self, kind)
273 axlabels = self.ax
274
--> 275 self._get_binner_for_resample(kind=kind)
276 grouper = self.grouper
277 binner = self.binner
/usr/local/lib/python2.7/dist-packages/pandas/tseries/resample.pyc in _get_binner_for_resample(self, kind)
121 kind = self.kind
122 if kind is None or kind == 'timestamp':
--> 123 self.binner, bins, binlabels = self._get_time_bins(ax)
124 elif kind == 'timedelta':
125 self.binner, bins, binlabels = self._get_time_delta_bins(ax)
/usr/local/lib/python2.7/dist-packages/pandas/tseries/resample.pyc in _get_time_bins(self, ax)
182
183 # general version, knowing nothing about relative frequencies
--> 184 bins = lib.generate_bins_dt64(ax_values, bin_edges, self.closed, hasnans=ax.hasnans)
185
186 if self.closed == 'right':
pandas/lib.pyx in pandas.lib.generate_bins_dt64 (pandas/lib.c:18952)()
ValueError: Values falls before first bin |
Yes, this is outstanding. It was a different type of issue that wasn't easily fixed at the time. |
Resampling to weekly works fine if we first remove the timezone:
And resampling the TZ-aware Series to daily works fine:
This issue is similar (but not identical) to #1459 and #8941
My install versions:
(as always, I must applaud the Pandas dev team. It's an awesome animal!)
The text was updated successfully, but these errors were encountered: