I have two pandas DataFrames df1 and df2 and I want to transform them in order that they keep values only for the index that are common to the 2 dataframes.
df1
Have you tried something like
df1 = df1.loc[[x for x in df1.index if x in df2.index]] df2 = df2.loc[[x for x in df2.index if x in df1.index]]