filter one dataframe by another

Solutions on MaxInterview for filter one dataframe by another by the best coders in the world

showing results for - "filter one dataframe by another"
Antonio
03 Nov 2019
1df1 = pd.DataFrame({'c': ['A', 'A', 'B', 'C', 'C'],
2                    'k': [1, 2, 2, 2, 2],
3                    'l': ['a', 'b', 'a', 'a', 'd']})
4df2 = pd.DataFrame({'c': ['A', 'C'],
5                    'l': ['b', 'a']})
6keys = list(df2.columns.values)
7i1 = df1.set_index(keys).index
8i2 = df2.set_index(keys).index
9df1[~i1.isin(i2)]