Hi,
Instructor used pd.to_numeric() as finction to convert objects to numbers.
He used ->
df.apply(pd.to_numeric)
to convert entire dataframe objects into numbers. Now when we use df.astype(){another function to convert object into number} we cannot directly write df.apply(df.astype()) as df.astype() requires a column name and it will show this error ->
We have to traverse through all columns but in order to do that, we have to convert dataframe into list and so .astype() cannot be applied.
How can I convert all df objects into numbers using df.astype() ?
PS: I don’t want to do this ->
df.astype({‘col1’ : ‘int32’ , ‘col2’ : ‘int32’ , … } )