Original DF has values that are calculated from a table.
It may have type missing for few ids.
However, the goal is explicitly list if the flag exists.
If not, type row should be added with no in the exists column.
id=1 is good in this example. If I filter on id=2 only, and run the following code, it returns c. which I can then append.
aa = set(type)
bb = set(b['type'].to_list())
list(aa - bb)
However, as you can tell, this is not feasible when applying to all id.
I needed help so the code can be applied for all the ids.
This returns the type that are no
type = [a, b, c]
Original
id type flag
1 a y
1 b y
1 c y
2 a y
2 b y
3 b y
Goal
id type flag exists
1 a y yes
1 b y yes
1 c y yes
2 a y yes
2 b y yes
2 c y no
3 a y yes
3 b y no
3 b y no
Hoping there is a better way to handle this.