Error converting object (string) to Int32: TypeError: object cannot be converted to an IntegerDtype
It's known bug, as explained here.
Workaround is to convert column first to float
and than to Int32
:
df.column = df.column.astype('float') # first convert to float before int
df.column = df.column.astype('Int32')
or simpler:
df.column = df.column.astype('float').astype('Int32')
Make sure you also strip your column from whitspaces before you do conversion:
df.column = df.column.str.strip()