-2

I have a csv file that contains values that are badly written. I want to correct these mistakes. for example replace Toyouta by toyota, maxda by mazda, in the column named carCompany. example.

The job I need to do is to predict the car price using these independent variables the beginning of my code

Has QUIT--Anony-Mousse
  • 70,714
  • 12
  • 123
  • 184
  • Possible duplicate of [Set value for particular cell in pandas DataFrame using index](https://stackoverflow.com/questions/13842088/set-value-for-particular-cell-in-pandas-dataframe-using-index) – Rishabh Deep Singh Jun 14 '19 at 11:11
  • you could use this package : https://pypi.org/project/pyspellchecker/ very helpful – Kaies LAMIRI Jun 14 '19 at 11:11

1 Answers1

1

DataFrame.replace(to_replace=None, value=None, inplace=False, limit=None, regex=False, method='pad')

eg.
>>> df = pd.DataFrame({'A': [0, 1, 2, 3, 4],
...                    'B': [5, 6, 7, 8, 9],
...                    'C': ['a', 'b', 'c', 'd', 'e']})
>>> df.replace(0, 5)
   A  B  C
0  5  5  a
1  1  6  b
2  2  7  c
3  3  8  d
4  4  9  e

df.replace('Toyouta','toyota')

should work.

Kacper
  • 394
  • 2
  • 8