As you know I can do df[df.column.isin(set)] to get the part of the DataFrame where the column value is in that set. But now my source set is dependent on the value of column1. How do I make the function lookup a dictionary for the source set on the go, as it filters the dataframe?
let's say i have
dict1={'a':[1,2,3],'b':[1,2],'c':[4,5,6]}
and my df looks like
column1 column2
a 4
b 2
c 6
and the new df should look like
column1 column2
b 2
c 6
Since 4 isn't in the list that 'a' points to in dict1.
new_df = df[df.column2.isin(dict1[df.column1])]
This gives me TypeError. I understand since i'm using pd.Series as keys and it's not hashable.