Moved original posted by @Bklyn in #2658 to here
I find I need to call tz_convert() on my DataFrame before I can plot it. By default the index tz is a "tzoffset" I get an exception when plottng.
AttributeError: 'module' object has no attribute 'tz' d=pd.read_csv('vix.dlmp.csv', parse_dates=[0], index_col=0) d.index.tz Out[23]: tzoffset(None, -18000) d['2012-12-28 09:30:15-05:00':] Out[24]: <class 'pandas.core.frame.DataFrame'> DatetimeIndex: 981 entries, 2012-12-28 09:30:16.311000-05:00 to 2012-12-28 09:59:46.518000-05:00 Data columns: Und 981 non-null values BidPrice 981 non-null values AskPrice 981 non-null values TradePrice 981 non-null values BidSize 981 non-null values AskSize 981 non-null values TradeSize 981 non-null values T0 981 non-null values T1 981 non-null values T2 981 non-null values T3 981 non-null values T4 981 non-null values T5 981 non-null values dtypes: float64(9), int64(3), object(1) d['2012-12-28 09:30:15-05:00':].plot(y=['BidPrice', 'AskPrice', 'TradePrice', 'T0', 'T1'],style=['g', 'b', 'r', 'k--', 'g--'],drawstyle='steps',figsize=(16,9))  --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-25-d7985a840c41> in <module>() ----> 1 d['2012-12-28 09:30:15-05:00':].plot(y=['BidPrice', 'AskPrice', 'TradePrice', 'T0', 'T1'],style=['g', 'b', 'r', 'k--', 'g--'],drawstyle='steps',figsize=(16,9)) /usr/local/lib/python2.7/dist-packages/pandas/tools/plotting.pyc in plot_frame(frame, x, y, subplots, sharex, sharey, use_index, figsize, grid, legend, rot, ax, style, title, xlim, ylim, logy, xticks, yticks, kind, sort_columns, fontsize, secondary_y, **kwds) 1419 grid=grid, logy=logy, secondary_y=secondary_y, 1420 title=title, figsize=figsize, fontsize=fontsize, -> 1421 **kwds) 1422 1423 plot_obj = klass(frame, kind=kind, subplots=subplots, rot=rot, /usr/local/lib/python2.7/dist-packages/pandas/tools/plotting.pyc in plot_series(series, label, kind, use_index, rot, xticks, yticks, xlim, ylim, ax, style, grid, legend, logy, secondary_y, **kwds) 1504 secondary_y=secondary_y, **kwds) 1505 -> 1506 plot_obj.generate() 1507 plot_obj.draw() 1508 /usr/local/lib/python2.7/dist-packages/pandas/tools/plotting.pyc in generate(self) 731 self._compute_plot_data() 732 self._setup_subplots() --> 733 self._make_plot() 734 self._post_plot_logic() 735 self._adorn_subplots() /usr/local/lib/python2.7/dist-packages/pandas/tools/plotting.pyc in _make_plot(self) 1063 lines = [] 1064 labels = [] -> 1065 x = self._get_xticks(convert_period=True) 1066 1067 plotf = self._get_plot_function() /usr/local/lib/python2.7/dist-packages/pandas/tools/plotting.pyc in _get_xticks(self, convert_period) 878 values for xaxis, several actions are already taken by plt. 879 """ --> 880 x = index._mpl_repr() 881 else: 882 self._need_to_set_index = True /usr/local/lib/python2.7/dist-packages/pandas/tseries/index.pyc in _mpl_repr(self) 474 def _mpl_repr(self): 475 # how to represent ourselves to matplotlib --> 476 return tslib.ints_to_pydatetime(self.asi8, self.tz) 477 478 def __repr__(self): /usr/local/lib/python2.7/dist-packages/pandas/tslib.so in pandas.tslib.ints_to_pydatetime (pandas/tslib.c:2998)() AttributeError: 'tzoffset' object has no attribute '_transition_info' In [26]: d=d.tz_convert('US/Eastern') In [27]: d['2012-12-28 09:30:15-05:00':].plot(y=['BidPrice', 'AskPrice', 'TradePrice', 'T0', 'T1'],style=['g', 'b', 'r', 'k--', 'g--'],drawstyle='steps',figsize=(16,9)) Out[27]: <matplotlib.axes.AxesSubplot at 0x4c25a50>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4