LOOKUP using 2 dataframes in Python I have 2 dataframes:

df1

Id     CategoryId 
1       A
1       B
2       A
2       E
2       F


df2: 

Id   A    B   C   D   E   F
1   
2    


I want to do a lookup which will help me fill up the values in df2 based on the values of df1

If df1 has id = 1 and CategoryId = A then I want df2 row 1 Column A to say Y else N

Final df2 should look like:

 Id   A    B   C   D   E   F
 1    Y    Y   N   N   N   N
 2    Y    N   N   N   Y   Y


I am not sure how to do this in Python.
I would really appreciate any help on this!

Thanks
If you have a dataframe df1 with two columns Id and CategoryId you can chain get_dummies and groupby, e.g. 

&gt;&gt;&gt; df2 = df1['CategoryId'].str.get_dummies().groupby(df1['Id']).max()
&gt;&gt;&gt; df2
    A  B  E  F
Id
1   1  1  0  0
2   1  0  1  1


It's not quite the format you wanted but it avoids the lookup.