Я пытаюсь создать словарь фреймов данных, импортированных из yahoo .
Это не работает:
import pandas_datareader.data as web
symbols = ['BTC-EUR','ETH-EUR' ]
dict_of_stock = { web.DataReader(s, "yahoo") for s in (symbols) }
Out:
/usr/local/lib/python3.6/dist-packages/pandas/core/generic.py in __hash__(self)
1797 def __hash__(self):
1798 raise TypeError(
-> 1799 f"{repr(type(self).__name__)} objects are mutable, "
1800 f"thus they cannot be hashed"
1801 )
TypeError: 'DataFrame' objects are mutable, thus they cannot be hashed
Однако это делает:
import pandas_datareader.data as web
symbols = ['BTC-EUR','ETH-EUR' ]
dict_of_stock = {}
for s in symbols:
#do some calcs to get a dataframe called 'df'
dict_of_stock[s] = web.DataReader(s, "yahoo")
В чем причина?