To keep array type as integer while having a NaN value with Python Pandas, to call dropna
to drop toe NaN values.
And then we call apply
to convert the remaining number values to ints.
For instance, we write
df.col = df.col.dropna().apply(lambda x: str(int(x)) )
to call dropna
to drop the NaN values from the col
column.
Then we call apply
with a lambda function that calls int
with x
to convert x
to an int.
And then we call str
to convert the int to a string.