I used this
df.astype({'year': int} )
trying to change the data type of the column 'year' to int (it is currently 'object') However, even after doing so, the column type doesn't change (it's still 'object')
What am I doing wrong?
CodePudding user response:
Since you are working with values of type 'object'
I recommend trying to transform it to string and then int
df['your_column_name'].astype(str).astype(int)
CodePudding user response:
It is inplace problem. Please use:
df['year'] = df.astype({'year': int})
So it works