Using astype(int) for strings with thousand separator

Mahmood Naderan nt_mahmood at yahoo.com
Sun Nov 14 10:41:01 EST 2021


Hi

While reading a csv file, some cells have values like '1,024' which I mean they contains thousand separator ','. Therefore, when I want to process them with 

  row = df.iloc[0].astype(int)

I get the following error

  ValueError: invalid literal for int() with base 10: '1,024'


How can I fix that? Any idea?



Regards,
Mahmood


More information about the Python-list mailing list