Vielleicht hilft das noch weiter, hier nochmal alles zusammengefasst.
Die Test.csv Datei sieht folgendermmaßen aus (aus Editor copy und paste):
A;B;C;D;E
0;0;nan ;0;0
0;0;nan ;0;0
0;0;nan ;0;0
0;0;99994,2;0;0
0;0;99976,7;0;0
0;0;99973,7;0;0
0;0;99973,2;0;0
0;0;99961,8;0;0
0;0;99958,5;0;0
118476;124464;99944,1;100129;99213,4
0;0;99943,5;0;0
0;0;99941,1;0;0
0;0;#NAME?;0;0
329476;377604;99934,3;113119;98933,5
0;0;99934,3;0;0
0;0;99912,6;0;0
0;0;99912,6;0;0
445309;511857;99890,3;123773;98871,4
0;0;1,04E+06;0;0
0;0;1,03E+06;0;0
0;0;1,01E+06;0;0
488017;560784;991210;128420;98836,8
0;0;989101;0;0
0;0;975643;0;0
0;0;968111;0;0
547193;628078;959356;135504;98780,4
0;0;916517;0;0
0;0;915653;0;0
der code den ich ausführe sieht so aus:
Code: Alles auswählen
import pandas as pd
link = 'Test.csv'
dfx = pd.read_csv(link, sep=";", decimal=",", dtype=float, na_values=["#NAME?",'nan'])
und die Fehlermeldung, die ich erhalte so :
Code: Alles auswählen
runcell(0, 'C:/Users/y/unbenannt18.py')
Traceback (most recent call last):
File "pandas\_libs\parsers.pyx", line 1151, in pandas._libs.parsers.TextReader._convert_tokens
TypeError: Cannot cast array from dtype('O') to dtype('float64') according to the rule 'safe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\y\unbenannt18.py", line 12, in <module>
dfx = pd.read_csv(link, sep=";", decimal=",", dtype=float, na_values=["#NAME?",'nan'])
File "C:\Program Files\Anaconda3_E2020\lib\site-packages\pandas\io\parsers.py", line 676, in parser_f
return _read(filepath_or_buffer, kwds)
File "C:\Program Files\Anaconda3_E2020\lib\site-packages\pandas\io\parsers.py", line 454, in _read
data = parser.read(nrows)
File "C:\Program Files\Anaconda3_E2020\lib\site-packages\pandas\io\parsers.py", line 1133, in read
ret = self._engine.read(nrows)
File "C:\Program Files\Anaconda3_E2020\lib\site-packages\pandas\io\parsers.py", line 2037, in read
data = self._reader.read(nrows)
File "pandas\_libs\parsers.pyx", line 859, in pandas._libs.parsers.TextReader.read
File "pandas\_libs\parsers.pyx", line 874, in pandas._libs.parsers.TextReader._read_low_memory
File "pandas\_libs\parsers.pyx", line 951, in pandas._libs.parsers.TextReader._read_rows
File "pandas\_libs\parsers.pyx", line 1083, in pandas._libs.parsers.TextReader._convert_column_data
File "pandas\_libs\parsers.pyx", line 1157, in pandas._libs.parsers.TextReader._convert_tokens
ValueError: could not convert string to float: '99994,2'
Habe sehr sehr viel gegoogelt, aber finde nichts.