- This topic has 1 reply, 2 voices, and was last updated 5 years, 3 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Home › Forums › Fórum Python para Finanças: Análise de Dados e Machine Learning › base de dados com mais acoes
acoes_df = pd.DataFrame()
for acao in acoes:
acoes_df[acao] = data.DataReader(acao, data_source=’yahoo’, start=’2015-01-01′)
erro
—————————————————————————
ValueError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in _ensure_valid_index(self, value)
3169 try:
-> 3170 value = Series(value)
3171 except (ValueError, NotImplementedError, TypeError) as err:
6 frames
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in _ensure_valid_index(self, value)
3173 “Cannot set a frame with no defined index ”
3174 “and a value that cannot be converted to a Series”
-> 3175 ) from err
3176
3177 # GH31368 preserve name of index
ValueError: Cannot set a frame with no defined index and a value that cannot be converted to a Series
Boa noite Pereira, esta faltando o atributo [‘Close’]. Veja abaixo como deve ficar:
acoes_df = pd.DataFrame() for acao in acoes: acoes_df[acao] = data.DataReader(acao, data_source='yahoo', start='2015-01-01')['Close']
Fabio