I constructed a dataframe which looks like this:
title category1 category2 category3 category4
'a' 0.44214 NAN 0.99 0.35
'b' NAN NAN NAN NAN
'c' 0.31 0.41 0.5 0.53
For each row, I want to indicate the two highest values with 1 and all others with 0.
Result should look like this:
title category1 category2 category3 category4
'a' 1 0 1 0
'b' 0 0 0 0
'c' 0 0 1 1
Is there a buildin-function solve this or how could this be implemented otherwise?