<｜begin▁of▁sentence｜>### Instruction:
Given a MultiGraph with edge attributes 'cost' and 'weight', can you convert the graph to a Pandas DataFrame including only the edges that have both nodes in the specified nodelist ['A', 'B']? Additionally, keep track of multiple edges by including edge keys.
### Response:
import networkx as nx
import pandas as pd

# Create a MultiGraph
G=nx.MultiGraph([
    ('A','B',{'cost':1,'weight':7}),
    ('A','C',{'cost':3,'weight':4}),
    ('B','C',{'cost':2,'weight':5})
])

# Convert to Pandas DataFrame
# Only including edges that have both nodes in the specified nodelist
# Also keeping track of multiple edges by including edge keys
df = nx.to_pandas_edgelist(G, nodelist=['A', 'B'], edge_key='ekey')

# Display the DataFrame with specified columns
print(df[['source', 'target', 'cost', 'weight', 'ekey']])
<|EOT|>
