Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How To Replace " . " With " , " on a pandas.DataFrame

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

We can replace . by , like so :

all_data_df['Column 5'] = all_data_df['Column 5'].astype(str).str.replace('.', ',', regex=True)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading