Carlos Arronte Bello Carlos Arronte Bello - 4 years ago 120
Python Question

Change value in specific row in padas

I need some help in python. I need to modify the value in an specific row. I have something like this.

ID Status Customer Name
345 New Braskem S.A
923 Closed Braskem
046 New Braskem S.A
195 New Braskem S.A
537 In Progress Braskem
237 On Hold Vale
355 Closed BIMBO


Here i need to change all the customer name "Braskem S.A" to "Braskem"
Can someone give me a hand with this please. Thanks I will appreciate the help and sorry for bad English.

Answer Source

There's a few ways to do this. Arguably the simplest is to use pandas.DataFrame.replace:

df.replace(to_replace='Braskem S.A', value='Braskem')

You can also use a boolean mask or a map.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download