0

I want to replace multiple string 'abc' to 0 in Pandas using loop. Example as below.

lnequipmon  equipten    lnequipten  callcard    cardmon
3.38        126.10      4.84        1.00        14.25
4.00        1975.00     7.59        1.00        16.00
abc         0.00        abc         1.00        23.00
abc         0.00        abc         1.00        21.00
abc         0.00        abc         1.00        17.25
3.57        970.95      6.88        1.00        28.25
abc         0.00        abc         0.00        0.00
abc         0.00        abc         1.00        14.50
abc         0.00        abc         1.00        15.50
abc         0.00        abc         0.00        0.00
3.44        1568.35     7.36        1.00        19.00
abc         0.00        abc         0.00        0.00 

i have more then 500 such values and more than 100 columns. Please help me how to replace these 'abc' to 0 using loop or function

feedMe
  • 3,431
  • 2
  • 36
  • 61

1 Answers1

0

You use a simple replace function.

>>> s = pd.Series([0, 1, 2, 3, 4])
>>> s.replace(0, 5)
0    5
1    1
2    2
3    3
4    4

For more information you can check out the documentation

Anna Jeanine
  • 3,975
  • 10
  • 40
  • 74