What I'm trying to achieve is that when a row in col2 has a 1, it will copy that 1 onto all the other values in col2 as long as the rows in col1 have the same name. As an example, if the dataframe looks like this
col1 col2
xx 1
xx 0
xx 0
xx 0
yy 0
yy 0
yy 0
zz 0
zz 0
zz 1
The output would be
col1 col2
xx 1
xx 1
xx 1
xx 1
yy 0
yy 0
yy 0
zz 1
zz 1
zz 1