I have Pandas data frame like this:
a b1 b2 b3 b4 c1 c2 c3 c4
a1 0.10 0.0 0.21 0.0 0.03 0.10 0.04 0.0
How can I change it to the following:
a b1 b2 b3 b4 c1 c2 c3 c4
a1 1 0 1 0 1 0 1 0
So, I want to select b* and c* columns and change any non-zero value into 1 and any zero value into 0. So, first selecting columns by regex then apply if-else rule there. It is also worth noting that all b*, c* columns are string (obj) types.
How can I do this?