Skip to content Skip to sidebar Skip to footer

Set Multiple Columns To Zero Based On A Value In Another Column

I have a sample dataset here. In real case, it has a train and test dataset. Both of them have around 300 columns and 800 rows. I want to filter out all those rows based on a certa

Solution 1:

Use the loc accessor; df.loc[boolean selection, columns]

df.loc[df['Name'].eq('Princi'),'Address':'Payment']=0



      Name  Age    Address  Payment Qualification
0     Jai   27      Delhi       15           Msc
1  Princi   24          0        0            MA
2  Gaurav   22  Allahabad       40           MCA
3  Princi   32          0        0           Phd
4    Anuj   66     Katauj        3            MA
5   Nancy   43    vbinauj       23            MS

Post a Comment for "Set Multiple Columns To Zero Based On A Value In Another Column"