# if you have this df named a , then you could try this code.
import numpy as np
import pandas as pd
a = pd.DataFrame(columns=["b","c","d","e"])
a.loc["title0",:] = [1,0,0,"string"]
a.loc["title1",:] = [0,1,1,"string"]
a.index.name = "a"
col_names = ['b','c','d']
for idx in a.index:
current_line = a.loc[idx,:]
process_part = current_line[col_names]
if sum(process_part)>1:
a = a.drop(idx)
for col,v in zip(col_names,process_part):
if v == 1:
keep_one = np.zeros(3)
keep_one[col_names.index(col)] = 1
a = a.append(pd.DataFrame.from_dict({idx:dict(zip(a.columns,list(keep_one)+[current_line[-1]]))},orient="index"))