![]() |
"'DataFrame' objects are mutable, thus they cannot be hashed" - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: "'DataFrame' objects are mutable, thus they cannot be hashed" (/thread-31641.html) |
"'DataFrame' objects are mutable, thus they cannot be hashed" - Mark17 - Dec-24-2020 I've been having trouble in a few instances with what I think is the same core issue--I just can't identify exactly what it is. markets = ['ES', 'GC', 'CL', 'EC', 'US'] margin_dict = {} for market in markets: df_name = market market = pd.read_csv(r'C:\Users\Mark17\{}(daily).csv'.format(market), parse_dates=["Date"], index_col="Date") margin_dict[df_name] = market.iloc[:,0].max() * 0.15 * trade_unit[df_name] * multiplier[df_name]This works. However, if I use "market" in place of "df_name" in the last line, then I get: TypeError: 'DataFrame' objects are mutable, thus they cannot be hashed Can someone please explain that? RE: "'DataFrame' objects are mutable, thus they cannot be hashed" - tinh - Dec-25-2020 You reassigned "market = pd.read_csv..." so absolutely it is not equal to df_name anymore, so cannot replace df_name with market |