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

.asfreq() dies when the index values have tzinfo associated with them #29

Closed
mpenning opened this issue Jan 11, 2011 · 2 comments
Closed

Comments

@mpenning
Copy link

>>> # dataframe is indexed at a second granularity, using eastern time
>>> dataframe                                                                   <class 'pandas.core.frame.DataFrame'>
Index: 24676 entries , 2010-10-04 00:03:49-04:00 to 2010-10-04 23:59:55-04:00
etf               10897  non-null values
etfvol            10897  non-null values
fut               17988  non-null values
futvol            17988  non-null values
ticx              7880  non-null values
vix               7465  non-null values
vixvol            7465  non-null values

>>> dataframe['etf'].index[0]
datetime.datetime(2010, 10, 4, 0, 3, 49, tzinfo=<DstTzInfo 'US/Eastern' EDT-1 day, 20:00:00 DST>)
>>>
>>> # et is a pytz timezone object for eastern time...
>>> et
<DstTzInfo 'US/Eastern' EST-1 day, 19:00:00 STD>

>>> dataframe['fut'].asfreq(et.localize(pn.DateOffset(seconds=1)), method='pad')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/pytz-2010o-py2.5.egg/pytz/tzinfo.py", line 262, in localize
    if dt.tzinfo is not None:
AttributeError: 'DateOffset' object has no attribute 'tzinfo'
>>>
>>> dataframe['fut'].asfreq(pn.DateOffset(seconds=1), method='pad')             Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/pandas/core/series.py", line 1103, in asfreq
    dateRange = DateRange(self.index[0], self.index[-1], offset=freq)
  File "/usr/lib/python2.5/site-packages/pandas/core/daterange.py", line 70, in __new__
    fromInside = start is not None and start > _CACHE_START
TypeError: can't compare offset-naive and offset-aware datetimes
>>>
@wesm
Copy link
Member

wesm commented Jun 3, 2011

I'm currently working on this issue, not sure when it'll be complete though. There's some level of tzinfo support in DateRange now, but I need to look a bit more closely at your use case-- there is the thorny issue of DST transitions.

@wesm
Copy link
Member

wesm commented Jun 23, 2011

Now have more robust tzinfo support in DateRange...have a look. Need to have a bit of an overhaul of the docs sometime in the near future

@wesm wesm closed this as completed Jun 23, 2011
stijnvanhoey pushed a commit to stijnvanhoey/pandas that referenced this issue Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants