Cleaning NaNs with averages pre or post split?
Imputing all missing values before the split would mean data leakage - you would use test set information to influence the training set.
I had a similar problem recently, I ended up using complete cases of the source data for the test set and then imputing the training data using medians calculated by class.
Otherwise, you might split the data and then impute the test set using the training set average/median/mode.