<｜begin▁of▁sentence｜>### Instruction:
Given a MultiGraph with edges [('A', 'B', {'cost': 1, 'weight': 7}), ('A', 'B', {'cost': 9, 'distance': 15})], how can we convert the graph's edge list including edge keys to a Pandas DataFrame using NetworkX?
### Response:
import networkx as nx
import pandas as pd

# Create a NetworkX graph
G = nx.MultiGraph()
# Add multiple edges between A and B with different attributes
g.add_edges_from([ ('A', 'B', {'cost': 1, 'weight': 7}), ('A', 'B', {'cost': 9, 'distance': 15}) ])
# Convert to Pandas DataFrame, including the edge keys for the MultiGraph
df = nx.to_pandas_edgelist(G, edge_key='ekey')
print(df[['source', 'target', 'cost', 'weight', 'ekey']])
<|EOT|>
