G_save = get_undirected(G.copy())
// create a GeoDataFrame of the nodes and set CRS
nodes = {node:data for node, data in G_save.nodes(data=True)}
gdf_nodes = gpd.GeoDataFrame(nodes).T
gdf_nodes.crs = G_save.graph["crs"]
// create a geometry column then drop the x and y columns
gdf_nodes["geometry"] = gdf_nodes.apply(lambda row: Point(row["x"], row["y"]), axis=1)
gdf_nodes = gdf_nodes.drop(["x", "y"], axis=1)
// make everything but geometry column a string
gdf_nodes["osmid"] = gdf_nodes["osmid"].astype(np.int64)
for col in [c for c in gdf_nodes.columns if not c == "geometry"]:
gdf_nodes[col] = gdf_nodes[col].fillna("").map(make_str)
// create a list to hold our edges, then loop through each edge in the graph
After Change
G_save = get_undirected(G.copy())
// create a GeoDataFrame of the nodes and set CRS
nodes_data = [data for _, data in G_save.nodes(data=True)]
gdf_nodes = gpd.GeoDataFrame(nodes_data, index=G_save.nodes(data=False))
gdf_nodes.crs = G_save.graph["crs"]