convert float with missing values to integer 1

convert float with missing values to integer

df['myCol'] = df['myCol'].astype('Int64')

Here is what the above code is Doing:
1. We’re creating a new column called ‘myCol’
2. We’re assigning the values of the ‘myCol’ column to be the values of the ‘myCol’ column
3. We’re converting the values of the ‘myCol’ column to be of type Int64

This is a very common pattern in pandas.

Similar Posts