There is a dataframe (df) in below format:
Name, Col-1, Col-2, Col-3, Col-4
abc, 0, 1, 0, 0
cba, 1, 0, 0, 0
bns 1, 0, 0, 0
abd 0 0, 0, 1
Now i am trying to add new column to this dataframe like below:
Name, Col-1, Col-2, Col-3, Col-4, Type
abc, 0, 1, 0, 0, Col-2
cba, 1, 0, 0, 0, Col-1
bns 1, 0, 0, 0, Col-1
abd 0 0, 0, 1, Col-4
Please suggest how to get it done, i tried below but throws error.
df['Type'] = [lambda x: x if x == 1 for x in df.columns]