I have this dataframe:
import polars as pl
dff = pl.DataFrame({'file':['a','a','a','a','b','b'],
'ru':['fe','fe','ev','ev','ba','br'],
'rt':[0,0,1,1,1,0],
})
dff
With the values:
file ru rt
"a" "fe" 0
"a" "fe" 0
"a" "ev" 1
"a" "ev" 1
"b" "ba" 1
"b" "br" 0
I’d like to update all ru and rt fields within the same file field, with the values of the first record, if the rt value of the first record rt == 0.
So the desired output would look like:
file ru rt
"a" "fe" 0
"a" "fe" 0
"a" "fe" 0
"a" "fe" 0
"b" "ba" 1
"b" "br" 0
How can I achieve that?