代码在iPython中完美运行,但在终端中运行时会出现错误消息

时间:2015-08-07 13:21:22

标签: python pandas dataframe

当我在iPython中运行此代码时,它完美无缺。但是当我从终端运行相同的脚本时,我收到一条错误消息:AttributeError: 'NoneType' object has no attribute 'unstack'

import pandas as pd
import pandas.io.data as web

stocks = {'xom': '2015-01-01', 'aapl': '2014-01-01', 'dvn': '2013-01-01'}

def fetch_data_from_yahoo(d_stocks):
    df_list = []
    for symbol, start_date in d_stocks.items():
        df_list.append(web.get_data_yahoo(symbol, start_date)['Adj Close'])
    return pd.concat(df_list, keys=list(d_stocks.keys()))

fetch_data_from_yahoo(stocks)

fetch_data_from_yahoo(stocks).unstack(0)

0 个答案:

没有答案