Session Ready
Exercise

Make nodelist

You're now going to practice converting graphs to pandas representation. If you have taken any of DataCamp's pandas courses, you will know that there is a DataFrame.to_csv('filename.csv') method that lets you save it as a CSV file, which is a human-readable version. The main concept we hope you take away from here is the process of converting a graph to a list of records.

Start by re-familiarizing yourself with the graph data structure by calling G.nodes(data=True)[0] in the IPython Shell to examine one node in the graph.

Instructions
100 XP
  • Initialize an empty node list called nodelist.
  • Use a for loop to iterate over the nodes of the G_people. Inside the loop:
    • Update the nodeinfo dictionary using the .update() method with d as the argument.
    • Append the nodeinfo dictionary to nodelist.
  • Create a pandas DataFrame of the nodelist called node_df using the pd.DataFrame() function.