ValueError: Input contains NaN, infinity or a value too large for dtype('float32')

in Machine Learning
Machine Learning Tutorials
2 Answers to this question

Here, in this scenario, we need to assume that X_test is a pandas dataframe. Hence, in this case, you can use DataFrame.fillna in order to replace the NAN values. Below is the representation.

 X_test.fillna(X_test.mean())

You can replace the NaN values with mean by using the following command,


X_test.fillna(X_test.mean())


If you want to remove the NaN values, use dropna().

If you want to unleash your potential in this competitive field, please visit the Machine Learning Training page for more information, where you can find the       and       as well.

For more updates on the latest courses stay tuned to HKR Trainings.

To Top