I have a table 'users' with a column 'Internet users' containing numeric values but they're as type object. I need to convert them to int, but:
When I try
users['Internet users'] = users['Internet users'].astype(int)I get an error "invalid literal for int() with base 10: '1,427,647,786'"When I try
pd.to_numeric(users['Internet users'],errors='coerce')it runs but returns all values as null. I need all the numeric values.I've tried
users['Internet users'] = int(float(users['Internet users']))but returns an error cannot convert the series to <class 'float'>
How can I convert this column to int avoiding returning null values?
ints then apparently. Also you can't useint()orfloat()on a list.locale.atoi).S = pd.Series(['1,427,647,786']); print(S.str.replace(',','').astype(int))