Home > Software design >  How To Replace " . " With " , " on a pandas.DataFrame
How To Replace " . " With " , " on a pandas.DataFrame

Time:11-08

I have a dataframe that includes some numbers like 25.300, 27.474 etc. As you can see the digits divided by "." but I need to divide them with ",".

Here is my code:

all_data_df['Column 5'][1:10]= all_data_df['Column 5'][1:10].replace(".",",")

But it doesn't work. How can I fix this issue?

CodePudding user response:

We can replace . by , like so :

all_data_df['Column 5'] = all_data_df['Column 5'].astype(str).str.replace('.', ',', regex=True)
  • Related