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

Piet van Oostrum piet-l at vanoostrum.org
Sun Sep 22 12:10:23 EDT 2019


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

> Hi,
>
> I have a table.csv file with the following structure:
>
> , Polyarene conc ,, mg L-1 ,,,,,,,
> Spectrum, Py, Ace, Anth,
> 1, "0,456", "0,120", "0,168"
> 2, "0,456", "0,040", "0,280"
> 3, "0,152", "0,200", "0,280"
>
> I open as dataframe with the command:
>
> data = pd.read_csv ('table.csv', sep = ',', skiprows = 1)
>
[snip]

> Also I'm also wondering if there would be any benefit of making this
> modification in dataframe before extracting the numeric fields to the
> array.
>
> Please, any comments or tip?

data = pd.read_csv ('table.csv', sep = ',', skiprows = 1, decimal=b',', skipinitialspace=True)

-- 
Piet van Oostrum <piet-l at vanoostrum.org>
WWW: http://piet.vanoostrum.org/
PGP key: [8DAE142BE17999C4]



More information about the Python-list mailing list