Do you have a dataset consisting of features, i.e. are the nan values indicate a missing feature?
If so, you could try to set them to the median value of this particular feature or to a categorical value indicating a missing feature, e.g. -1.
But I think it depends on the data you have.
Could you explain what kind of data you have and why the NaNs are there?