text [股票数据提取]考虑到Pandas_Datareader不再适用于雅虎数据,获取股票数据。 #pandas #e

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text [股票数据提取]考虑到Pandas_Datareader不再适用于雅虎数据,获取股票数据。 #pandas #e相关的知识,希望对你有一定的参考价值。

# Dependencies
import pandas as pd
import fix_yahoo_finance as yf  

# Retrieve Tickers from S&P 100
df = list(pd.read_excel("SP100Tickers.xlsx")['Tickers'])

# Attempts to gather data from the period 2004-01-01 until 2015-0-01
# If the Data is unavailable (company does not exist yet) it will
# pass a ValueError, if so, the company is skipped
try:
    data = yf.download(df,"2004-01-01","2015-01-01")['Adj Close']
except ValueError:
    pass

# Check Data Output
display(data.head())
print("The shape of the data is as follows (rows, columns):",data.shape)

以上是关于text [股票数据提取]考虑到Pandas_Datareader不再适用于雅虎数据,获取股票数据。 #pandas #e的主要内容,如果未能解决你的问题,请参考以下文章