Building the graph
Now that we've imported our data, let's build our graph. To do this, we're going to build the structure for our vertices and edges. At the time of writing, GraphFrames requires a specific naming convention for vertices and edges:
The column representing the vertices needs to have the name of
id. In our case, the vertices of our flight data are the airports. Therefore, we will need to rename the IATA airport code toidin ourairportsDataFrame.The columns representing the edges need to have a source (
src) and destination (dst). For our flight data, the edges are the flights, therefore thesrcanddstare the origin and destination columns from thedepartureDelays_geoDataFrame.
To simplify the edges for our graph, we will create the tripEdges DataFrame with a subset of the columns available within the departureDelays_Geo DataFrame. As well, we created a tripVertices DataFrame that simply renames the IATA column to id to match the GraphFrame naming convention:
# Note, ensure...