Financial Plots in Python -
i trying graph candlestick stock charts in python. code have works fine except last line generates error message , don't know how fix it. appreciate help.
import plotly plotly.__version__ import plotly.plotly py plotly.tools import figurefactory ff datetime import datetime import pandas.io.data web df = web.datareader("aapl", 'yahoo', datetime(2007, 10, 1), datetime(2009, 4, 1)) fig = ff.create_candlestick(df.open, df.high, df.low, df.close, dates=df.index) py.iplot(fig, filename='finance_aapl_candlestick', validate=false) >>> py.iplot(fig, filename='finance_aapl_candlestick', validate=false) traceback (most recent call last): file "<stdin>", line 1, in <module> file "c:\python27\lib\site-packages\plotly\plotly\plotly.py", line 151, in iplot url = plot(figure_or_data, **plot_options) file "c:\python27\lib\site-packages\plotly\plotly\plotly.py", line 241, in plot res = _send_to_plotly(figure, **plot_options) file "c:\python27\lib\site-packages\plotly\plotly\plotly.py", line 1374, in _send_to_plotly cls=utils.plotlyjsonencoder) file "c:\python27\lib\json\__init__.py", line 250, in dumps sort_keys=sort_keys, **kw).encode(obj) file "c:\python27\lib\site-packages\plotly\utils.py", line 145, in encode encoded_o = super(plotlyjsonencoder, self).encode(o) file "c:\python27\lib\json\encoder.py", line 207, in encode chunks = self.iterencode(o, _one_shot=true) file "c:\python27\lib\json\encoder.py", line 270, in iterencode return _iterencode(o, 0) file "c:\python27\lib\site-packages\plotly\utils.py", line 208, in default return encoding_method(obj) file "c:\python27\lib\site-packages\plotly\utils.py", line 270, in encode_as_datetime obj = obj.astimezone(pytz.utc) file "tslib.pyx", line 288, in pandas.tslib.timestamp.tz_convert (pandas\tslib.c:7178) exception: cannot convert tz-naive timestamp, use tz_localize localize
the last entry in stack trace indicates timestamps missing time zone information. see http://pandas.pydata.org/pandas-docs/stable/timeseries.html#time-zone-handling
in particular, @ tz_localize @ in [301]:
near bottom of page.
Comments
Post a Comment