0

I have a dataset which has as separator ; but I want , to be the new separator. I'm currently using pandas.Dataframe.replace to achieve it, but it seems like there is no effect. The dataset is something like this:

A; B; C; D; E
1; 32; 234; 2; 23
2; 3; 1; 55; 545
3; 44; 12; 1; 3
...
yoyoyo
  • 119
  • 1
  • 7
  • 2
    What is reason for it? Do you need create `A-E` columns and `df = pd.read_csv(file)` failed? Then use `df = pd.read_csv(file, sep=';')` – jezrael Aug 22 '20 at 15:43

1 Answers1

1

You need turn the regex on

df = df.replace({';':','},regex=True)
BENY
  • 296,997
  • 19
  • 147
  • 204
  • 1
    Hard to know if it is correct answer (if data are in one column or not). So if answer should be changed from `df = df.replace({';':','},regex=True)` be free reopen answer, please. – jezrael Aug 22 '20 at 15:40
  • How can I save this changes in my dataset permanently? – yoyoyo Aug 22 '20 at 15:42
  • 1
    @yoyoyo after assign it is permanently ~ `df = df.replace({';':','},regex=True) ` – BENY Aug 22 '20 at 15:44