Numbers are indicated as string after reading a csv although I use "thousands="

Viewed 20

I have a csv available that lists numbers as follows:

4,872 ; 3,701 ; 2,018 ; 5,605 

Now I want to read this csv and use the following code:

for file in all_files:
    df = pd.read_csv(file, sep=";", thousands=',')

Unfortunately, the values are not listed as int, but as strings although I use "thousands=". E.g.:

' 3,701 ', ' 2,018 '

How do I fix the problem? Is it caused by the spaces?

0 Answers
Related