import pandas as pd

# create two sample dataframes
df1 = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]})
df2 = pd.DataFrame({'A': [2, 3, 4], 'B': [5, 6, 7], 'D': [8, 9, 10]})

# set the indexes to columns A and B and get their intersection
df1.set_index(['A', 'B'], inplace=True)
df2.set_index(['A', 'B'], inplace=True)
index = df1.index.intersection(df2.index)

# join the two dataframes with inner join using the common index
result = pd.merge(df1.loc[index], df2.loc[index], on=['A', 'B'], how='inner')

# reset the index to columns A and B
result.reset_index(inplace=True)

# display the joined dataframe
print(result)