MyI would like to replace NaN values in Target with the corresponding Node value. My data is
Node Target Color node1 node7 Red node1 node9 Red node3 node5 Green node1 node3 Red node3 node1 Red node5 NaN Yellow
I would like to treat nodes with no target (nan) as isolated nodes. Doing
from pymnet import * import matplotlib.pyplot as plt name='Layer1' mnet = MultilayerNetwork(aspects=1) for index in df.index: mnet[df.loc[index, 'Node'], df.loc[index, 'Target'], name,name] = 1 fig=draw(mnet, show=True, defaultLayerColor="whitesmoke", nodeSizeRule={"rule":"degree","propscale":0.05}, figsize=(25,30))
I have encountered the erroor
TypeError: 'Series' objects are mutable, thus they cannot be hashed
(due to: ----> 9 mnet[df.loc[index, 'Node'], df.loc[index, 'Target'], name,name] = 1)
I would say it is because of the nan value. I think that a possible solution could be using an if statement to check if a node has Target equal to NaN: if yes, than it would be possible to assign itself as target. Do you know how I could replace these values in orderneed to have:
Node Target Color node1 node7 Red node1 node9 Red node3 node5 Green node1 node3 Red node3 node1 Red node5 node5 Yellow # here the replacement
I think that a possible solution could be using an if statement to check if a node has Target equal to NaN: if yes, than it would be possible to assign itself as target.