0

i have the list of nodes but I don't have the list of edges which is essential for graph but there is relationship b/w nodes through patient id and provider id how to convert csv in proper format so the id column in this image represent nodes but I need edge list those nodes that have common provider and patient id will form edge how to convert this csv file in proper format

  • 1
    I think you need to groupby get a list of nodes then create graph from that nodelist. If you create a simple mock dataset, this would help greatly with answering your question. https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – Scott Boston Mar 31 '22 at 14:49
  • thank you very much @ScottBoston it seems its will work it returns the list of indexes but not value do you know any pandas method that will help me to get Id values list instead of indexes i used edges = dataframe.groupby(['PATIENTID'])['Id'] to make groups edges.groups to extract the dictionary of groups here is what i have recieved '000869e9-2019-56e5-ec22-8ed0bcb081bc': [546218, 546219, 546220, 546221, 546222, 546223, 546261, 546262, 546272, 546274, 546279, 546282, 546283, 546284, 546292, 546296, 546298, 546300, 546302, 546304, 546306, 546309, 546310] i need just list of ids values – Jawad Hayat Shreef Apr 01 '22 at 06:31

1 Answers1

0

In networkx, for the following:

edges = dataframe.groupby('PATIENTID')['Id'].apply(list)  

This works for me and I got the list of nodes against each patient id.

Eitan
  • 1,286
  • 2
  • 16
  • 55