I have a dataframe in pandas for which i'm trying to create a graph. Here's the data.
**source** **destination** **type**
London New York Arrival
New York Dubai Departure
Manchester Visakhapatnam Departure
New Delhi London Departure
Visakhapatnam Dubai Arrival
I created a list in pandas and got all the unique places into a list like this:
places = ['London', 'New York', .......]
and then converted it into a datafame and created nodes using this query:
def add_unique_places(tx,df_places):
for index,row in df_places.iterrows():
tx.run("""
CREATE (place:P {name: $label1})
""",
parameters={'label1':row['Places']})
Now i divided the data into two dataframes. One for type "Arrival" and one for type "Departure".
All i want now is to create a graph like this:
(London)-[:Arrival]->(New York)
How to achieve this?
PS:
WIthout doing all the above process, i directly took the dataframe and created a graph and merged nodes using apoc. But theres a problem.
Since "London" is in both 'source' and 'destination', it's creating two different nodes but i only want one node.
Thank You!
Peace!