Closed
Description
I have a DataFrame with a DateTime index that I have read from a CSV file:
In [131]: d=pd.read_csv('data.csv', parse_dates=[0], index_col=0)
The index values consist of ISO-8601-formatted timestamps of the form "2012-12-28T09:00:54.273000-0500", which Pandas seems to handle perfectly:
In [132]: d.index
Out[132]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-12-28 09:00:54.272000, ..., 2012-12-28 09:59:46.518000]
Length: 1310, Freq: None, Timezone: tzoffset(None, -18000)
But if I try to access data using stringified times, I get this error (I've left the last 2 stack fames for brevity):
In [133]: d['2012-12-28 09:30:00-05:00':]
---------------------------------------------------------------------------
DateParseError Traceback (most recent call last)
<ipython-input-133-4564ed4dbf71> in <module>()
----> 1 d['2012-12-28 09:30:00-05:00':]
<...elided...>
/usr/local/lib/python2.7/dist-packages/pandas/tseries/index.pyc in _get_string_slice(self, key)
1126 freq = getattr(self, 'freqstr',
1127 getattr(self, 'inferred_freq', None))
-> 1128 asdt, parsed, reso = parse_time_string(key, freq)
1129 key = asdt
1130 loc = self._partial_date_slice(reso, parsed)
/usr/local/lib/python2.7/dist-packages/pandas/tseries/tools.pyc in parse_time_string(arg, freq, dayfirst, yearfirst)
234 yearfirst=yearfirst)
235 except Exception, e:
--> 236 raise DateParseError(e)
237
238 if parsed is None:
DateParseError: global name 'tz' is not defined
If I specify the timestamp without the GMT offset, I must specify it in GMT (e.g. 9:30am my time is "2012-12-28 14:30:00") which is awkward. I can use localized datetime objects instead of strings, but this is also a bit of a pain.
Is there a fix for this "tz" error so I can use plain ol' strings? Thanks!