我一直在尝试从雅虎财经中提取数据,但我不断收到这个奇怪的错误。
所以我运行这段代码:
#Importing Modules/Libraries
import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
from pandas_datareader import data, wb
import fix_yahoo_finance as yf
yf.pdr_override()
import numpy as np
import datetime
import seaborn as sns
import matplotlib.pyplot as plt
And I get a feedback from my console with this error :
#Importing Modules/Libraries
import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
from pandas_datareader import data, wb
import fix_yahoo_finance as yf
yf.pdr_override()
import numpy as np
import datetime
import seaborn as sns
import matplotlib.pyplot as plt
#Importing Historical data from yahoo finance
tickers =
['XSLV','SMLV','XMLV','USMV','LGLV','SPLV','PRFZ','PXSC','FNDB','PXMC','PRF','QQ
EW','RSP','EQWL','EQAL','EWMC','EWSC',
'DWAS','MMTM','PDP','DWAQ','QUAL','SPHQ','^PHB','ACWV','IDLV','EELV','PDN','PXH'
,'QWLD','IQLT','IQDF','IDMO','EEMO',
'PIZ','PIE']
indices = pd.DataFrame()
for t in tickers:indices[t]=data.get_data_yahoo(t, data_source='yahoo',start='2016-1-1')['Adj Close']
输出:
[ 0% ]
[*********************100%***********************] 1 of 1 downloaded
[ 0% ]
[*********************100%***********************] 1 of 1 downloaded
[ 0% ]
[*********************100%***********************] 1 of 1 downloaded
[ 0% ]
[*********************100%***********************] 1 of 1 downloaded
[ 0% ]
[*********************100%***********************] 1 of 1 downloaded
[ 0% ]
[*********************100%***********************] 1 of 1 downloaded
[ 0% ]
[*********************100%***********************] 1 of 1 downloaded
[ 0% ]
[*********************100%***********************] 1 of 1 downloaded
Traceback (most recent call last):
File "<input>", line 18, in <module>
File "C:\Users\TIM\PycharmProjects\BILLIONAIRE'S CLUB\venv\lib\site-
packages\fix_yahoo_finance\__init__.py", line 202, in download
'Close', 'Adj Close', 'Volume']]
File "C:\Users\TIM\PycharmProjects\BILLIONAIRE'S CLUB\venv\lib\site-
packages\pandas\core\frame.py", line 2682, in __getitem__
return self._getitem_array(key)
File "C:\Users\TIM\PycharmProjects\BILLIONAIRE'S CLUB\venv\lib\site-
packages\pandas\core\frame.py", line 2726, in _getitem_array
indexer = self.loc._convert_to_indexer(key, axis=1)
File "C:\Users\TIM\PycharmProjects\BILLIONAIRE'S CLUB\venv\lib\site-
packages\pandas\core\indexing.py", line 1308, in _convert_to_indexer
obj, kind=self.name)
File "C:\Users\TIM\PycharmProjects\BILLIONAIRE'S CLUB\venv\lib\site-
packages\pandas\core\indexes\multi.py", line 1968, in _convert_listlike_indexer
_, indexer = self.reindex(keyarr, level=level)
File "C:\Users\TIM\PycharmProjects\BILLIONAIRE'S CLUB\venv\lib\site-
packages\pandas\core\indexes\multi.py", line 2057, in reindex
keep_order=False)
File "C:\Users\TIM\PycharmProjects\BILLIONAIRE'S CLUB\venv\lib\site-
packages\pandas\core\indexes\base.py", line 3969, in _join_level
ngroups = 1 + new_lev_labels.max()
File "C:\Users\TIM\PycharmProjects\BILLIONAIRE'S CLUB\venv\lib\site-
packages\numpy\core\_methods.py", line 26, in _amax
return umr_maximum(a, axis, None, out, keepdims)
ValueError: zero-size array to reduction operation maximum which has no identity.