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?
Python Pandas – Change Data Type of a Specific Column
pandaspython
Best Answer
df['colname'] = df['colname'].astype(int)
works when changing fromfloat
values toint
atleast.