Resetando os índices e renomenado a coluna dos ativos
cotacoes = cotacoes.reset_index().rename(columns={'level_1': 'Ativo'})
Organizando o df
cotacoes = cotacoes[["Date", "Open", "High", "Low", "Close", "Ativo"]]
apos essas rodarem certo
KeyError Traceback (most recent call last)
<ipython-input-18-51ad5c67136e> in <cell line: 2>()
1 # Organizando o df
----> 2 cotacoes = cotacoes[["Date", "Open", "High", "Low", "Close", "Ativo"]]
2 frames
/usr/local/lib/python3.10/dist-packages/pandas/core/indexes/base.py in _raise_if_missing(self, key, indexer, axis_name)
6131
6132 not_found = list(ensure_index(key)[missing_mask.nonzero()[0]].unique())
-> 6133 raise KeyError(f"{not_found} not in index")
6134
6135 @overload
KeyError: "['Ativo'] not in index"