Home > Blockchain >  Replace dot with comma using pandas on dataframe
Replace dot with comma using pandas on dataframe

Time:10-24

I have a large dataframe which combines data from multiple excel (xlsx) files. The problem is every column with decimal values is seperated with a dot.I need to replace every dot with a comma. I have already tried using the replace function, but the issue some columns also contains string values. So my question is, how do I replace dot with comma on each column in my dataframe and also keep the string values?

Example:

Column a:
14.01 -> 14,01
No data (keep)

CodePudding user response:

You can just use the decimal parameter of pandas. As described in the manual: pandas.read_excel

CodePudding user response:

This is probably your default language setting for Office tool is US or UK where . is used a decimal denoter where as in languages like German it is a ,. If you are using Libre Office, you can go to Tools -> Language -> For all text -> More and change the default decimal separator key. If you are using Microsoft excel, there should be something similar. Afterwards save the excel and then open it back in pandas. Voila.

  • Related