<｜begin▁of▁sentence｜>### Instruction:
Given two dataframes, one containing edge data with 'source' and 'target' columns and another containing vertex data with 'name' and an 'attribute' column, how can you generate a directed igraph graph object from these dataframes, while ensuring that vertex IDs correspond to the index of the vertex dataframe?
### Response:
import igraph as ig
import pandas as pd

# Create a sample edges DataFrame
data_edges = {'source': [0, 1, 2], 'target': [1, 2, 3]}
edges_df = pd.DataFrame(data_edges)

# Create a sample vertices DataFrame
data_vertices = {'name': ['A', 'B', 'C', 'D'], 'attribute': ['attr1', 'attr2', 'attr3', 'attr4']}
vertices_df = pd.DataFrame(data_vertices)
vertices_df.index = [0, 1, 2, 3]

# Generating a graph from the dataframes
g = ig.Graph.DataFrame(edges_df, directed=True, vertices=vertices_df)

# Inspect the graph
print(g)
print(g.vs['name'])
print(g.vs['attribute'])
print(g.es['source', 'target'])
<|EOT|>
