Seite 1 von 1

ValueError: could not convert string to float: '825,00'

Verfasst: Mittwoch 20. Oktober 2021, 11:52
von monkiiiii
df['GazeRightx'] = df['GazeRightx'].astype('float')
df.dtypes

ValueError: could not convert string to float: '825,00'


Hat jemand eine Idee, wo das Problem liegt? So weit ich die Daten im Blick habe, gibt es keine missing values o.ä. in der Column

LG, monkiiiii

Re: ValueError: could not convert string to float: '825,00'

Verfasst: Mittwoch 20. Oktober 2021, 11:57
von pillmuncher
Der Dezimaltrenner muss wohl ein Punkt sein, kein Komma.

Re: ValueError: could not convert string to float: '825,00'

Verfasst: Mittwoch 20. Oktober 2021, 12:10
von Sirius3
Der Fehler liegt daran, dass Du ein Dataframe mit Strings statt mit Zahlen hast.
Die Umwandlung findet direkt beim Lesen statt. read_csv hat zum Beispiel den decimal-Parameter, den man auf Komma umstellen kann.