title: ValueError: Input contains NaN, infinity or a value too large for dtype('float32'). Why?
body: <p>I have gone through all the similar questions but none of them answer my query. I am using random forest classifier as follows:</p>
  
  <pre class="lang-py prettyprint-override"><code>from sklearn.ensemble import RandomForestClassifier
  clf = RandomForestClassifier(n_estimators=100, max_depth=2, random_state=0)
  clf.fit(X_train, y_train)
  clf.predict(X_test)
  </code></pre>
  
  <p>It's giving me this error:</p>
  
  <p><code>ValueError: Input contains NaN, infinity or a value too large for dtype('float32').</code></p>
  
  <p>However, when I do <code>X_train.describe()</code> I don't see any missing values. In fact, actually, I already took care of the missing values before even splitting my data. </p>
  
  <p>When I do the following:</p>
  
  <p><code>np.where(X_train.values &gt;= np.finfo(np.float32).max)</code></p>
  
  <p>I get:</p>
  
  <p><code>(array([], dtype=int64), array([], dtype=int64))</code></p>
  
  <p>And for these commands:</p>
  
  <pre class="lang-py prettyprint-override"><code>np.any(np.isnan(X_train)) #true
  np.all(np.isfinite(X_train)) #false
  </code></pre>
  
  <p>And after getting the above results, I also tried this:</p>
  
  <p><code>X_train.fillna(X_train.mean())</code></p>
  
  <p>but I get the same error and it doesn't fix anything.</p>
  
  <p>Please tell me where I'm going wrong. Thank you!</p>