Boomshakalaka
Boomshakalaka

Reputation: 521

How should I change the value to 0 without remove the rows

I have a dataframe which contains three rows, and I want to make the amount to 0 for those LeadID? =0 (not a leaddeal). Don't remove them. Can anyone help me with this? Thanks for the help.

raw data

LeadID  LeadID? Amount
31578    1       $189
17698    1       $187
21891    1       $191
25062    1       $127
25062    0       $127
15133    1       $167
15133    0       $167
14321    1       $122
19148    1       $181

rows

DataFrame

Upvotes: 3

Views: 55

Answers (2)

AntonioTorro
AntonioTorro

Reputation: 199

for x in LeadID(8):
if x == 1:
   x == 0
    break

I haven't used Python in a long time but should be something simple like this. I'm also assuming there's only 8 fields. If there's more, add that number, keeping in mind that 0 is the first index.

Upvotes: 0

Kevin K.
Kevin K.

Reputation: 1397

You can assign values to slices of your dataframe by indexing using loc:

df.loc[df['LeadID?'] == 0, 'Amount'] = '$0'

Upvotes: 2

Related Questions