我想了解為什么會出現(xiàn)此錯誤:TypeError: unhashable type: 'set',當我運行此代碼時import matplotlib.pyplot as pltimport networkx as nxdef my_function(file): file = file.explode('Two') G = nx.DiGraph() nx.add_path(G, file['One']) nx.add_path(G, file['Two']) nx.draw_networkx(G) plt.show() return使用此數(shù)據(jù)集: One Twowine {wine, beer, wine, water}table {table, oven, chair, kitchen} car {cars, bike, bike}我沒有使用set(nor frozenset),但我認為問題可能出在括號中。
1 回答

紫衣仙女
TA貢獻1839條經(jīng)驗 獲得超15個贊
添加路徑時,您可以explode
先添加數(shù)據(jù)框
df = df.assign(Two=df.Two.map(list)).explode('Two')
添加回答
舉報
0/150
提交
取消