Most efficient way to replace ", " with "." in a array and/or dataframe

Piet van Oostrum piet-l at vanoostrum.org
Mon Sep 23 03:43:02 EDT 2019


Markos <markos at c2o.pro.br> writes:

[...]
>>> Please, any comments or tip?
>> data = pd.read_csv ('table.csv', sep = ',', skiprows = 1, decimal=b',', skipinitialspace=True)
>>
> Thank you for the tip.
>
> I didn't realize that I could avoid formatting problems in the dataframe
> or array simply by using the read_csv command with the correct
> parameters (sep and decimal).
>
> I searched for information about the meaning of the letter "b" in the
> parameter decimal=b','  but didn't find.
>
> I found that it also works without the letter b.
>

I added the b because the default in the definition of read_csv is b'.', but you are right, it works with just ','.
-- 
Piet van Oostrum <piet-l at vanoostrum.org>
WWW: http://piet.vanoostrum.org/
PGP key: [8DAE142BE17999C4]



More information about the Python-list mailing list