In my software user can load different types of a dataset using Pandas. if the software was installed on windows with English locale where the decimal separator symbol is dot (.) I will pass this char to for example read_csv function. like:
df = pd.read_csv("example.csv", decimal='.')
but it can also be installed on, for example, German locale PC where the decimal separator is the comma (,). I can get the current local using:
import locale
locale.getdefaultlocale()
but it's also possible that in german local the separator is the dot (.). Now the question is how can I explicitly know what is the decimal separator character in python so that I can parse the dataset correctly?
I am so stupid. it was right in the documentation
locale.localeconv()["decimal_point"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With