2016-05-24 6 views
1

私はbokehで時系列グラフを表示しようとしていますが、私は "TimeSeries"という名前をインポートできませんというエラーメッセージが表示されます。私はbokehとPythonには非常に新しいので、任意のすべての助けが大いに感謝されます。「名前をインポートできません」というエラーが表示されるのはなぜですか?

from yahoo_finance import Share 
import pandas as pd 
from bokeh.charts import TimeSeries, output_file, show 

# Getting stocks from Yahoo Finance 
yahoo = Share('YHOO') 
google = Share('GOOGL') 

# User selects stocks 
stock = input("Enter stock name: ") 
choice = Share(stock) 

yahoo.refresh() 
choice.refresh() 

# gets stock data for a desired Stock 
yahooData = choice.get_historical('2016-05-01', '2016-05-23') 

# all dates are stored here 
date = [] 

# all stock prices are stored here 
data = [] 

# sanity check to see if the thing works 
for i in range(10): 
    date.append(yahooData[i]['Date']) 
    data.append(yahooData[i]['Adj_Close']) 
    print(date[i], data[i], sep=' ') 

# turns the two lists into a data frame 
stock_data = pd.DataFrame({'Dates': date , 'Prices' : data}) 
stock_data 

# Where things go to s**t 
p = TimeSeries(stock_data, index = 'Dates', legend = 'True', title = "Stock Chart", ylabel = 'Prices') 
output_file("Stock_chart.html") 
show(p) 

このエラーを得られます。

はImportErrorトレースバック(最新の呼び出しの最後) bokeh.chartsからPD ----> 3としてyahoo_financeの輸入シェア 2輸入パンダから1 )(中'なTimeSeries'

名前をインポートすることはできません:インポートなTimeSeriesは、output_fileは、

はImportErrorヤフー・ファイナンスから 5#取得株式を示し、

+0

コンソールから完全なトレースバックを表示できますか? – Broly

+0

モジュールbokehの一部をインポートできましたか?私はこれがモジュールのインストールの問題だと思います。 –

+0

この例を実行するには古いバージョンのBokehがインストールされているか、インストールに問題があります。 – bigreddot

答えて

1

bokeh 0.10.x以下のバージョンを使用している可能性があります。 bokehのshow、output_fileのサポートは、0.11.1以降に追加されました。あなたのbokehバージョンを0.12.4に更新すると、すべて設定されます。

関連する問題