I have a pandas dataframe position
row column
1 3 Brazil
2 6 USA
3 3 USA
4 7 Canada
and another x
Brazil Canada USA
1 False False False
2 False False False
3 False False False
4 False False False
5 False False False
6 False False False
7 False False False
I want to populate the second one based on the values from the first one, so the result is:
Brazil Canada USA
1 False False False
2 False False False
3 True False True
4 False False False
5 False False False
6 False False True
7 False True False
I'm doing that using iterrows()
for i, r in positions.iterrows():
x.at[r['row'],r['column']] = True
Is there a faster way to do that?