I have two data frames like this:
df_1
Use Index.isin with boolean indexing:
Index.isin
boolean indexing
df3 = df2[df2.index.isin(df1['index_col'])]
Or DataFrame.merge:
DataFrame.merge
df3 = (df2.merge(df1[['index_col']], left_index=True, right_on='index_col') .drop('index_col', axis=1))
1.4m articles
1.4m replys
5 comments
57.0k users