Python Pandas – Change Data Type of a Specific Column

pandaspython

I want to sort a dataframe with many columns by a specific column, but first I need to change type from object to int. How to change the data type of this specific column while keeping the original column positions?

Best Answer

df['colname'] = df['colname'].astype(int) works when changing from float values to int atleast.

Related Question