我想了解為什么會(huì)出現(xiàn)此錯(cuò)誤:TypeError: unhashable type: 'set',當(dāng)我運(yùn)行此代碼時(shí)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),但我認(rèn)為問題可能出在括號(hào)中。
1 回答

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