I have this dataframe .
drinks sex
0 1 1
1 1 1
2 1 1
3 1 2
4 1 2
5 1 2
6 1 2
7 2 1
8 2 1
9 2 1
10 1 2
11 1 2
12 3 2
13 3 1
14 3 1
15 2 1
16 2 1
17 2 1
And these two dictionaries:
d_1 = {1 :'cola', 2 :'pepsi', 3 : 'fanta'}
d_2 = {1 :'m', 2 : 'f'}
I want to filter the values in my dataframe, but by linking the keys of dictionary. For ex if i give:
df[ df['drinks'] == 'cola']
then the output should look like this:
drinks sex
1 1
1 1
1 1
1 2
1 2
1 2
1 2
1 2
1 2
The idea is here not to give the values of dataframe column but to give the values of dictionary and it should filter the values in dataframe. I tried writing a function but didn't work. Any idea, how to acheive this. thanks!!!!