Skip to content Skip to sidebar Skip to footer

Filling Nan And Converting To Int Pandas

I have a dataframe of integers. Preview (starts from 3 due to first 3 rows removal): The original data in the 'pixel1' column is int, but the NAN there forced it to float. I tried

Solution 1:

I suggest use ffill with bfill for back filling if possible some NaNs in first row:

X_train = X_train.ffill().bfill().astype(int)

If not:

X_train = X_train.ffill().astype(int)

Post a Comment for "Filling Nan And Converting To Int Pandas"