title: Python pandas: how to remove nan and -inf values
body: <p>I have the following dataframe</p>
  
  <pre><code>           time       X    Y  X_t0     X_tp0  X_t1     X_tp1  X_t2     X_tp2
  0         0.002876    0   10     0       NaN   NaN       NaN   NaN       NaN
  1         0.002986    0   10     0       NaN     0       NaN   NaN       NaN
  2         0.037367    1   10     1  1.000000     0       NaN     0       NaN
  3         0.037374    2   10     2  0.500000     1  1.000000     0       NaN
  4         0.037389    3   10     3  0.333333     2  0.500000     1  1.000000
  5         0.037393    4   10     4  0.250000     3  0.333333     2  0.500000
  
  ....
  1030308   9.962213  256  268   256  0.000000   256  0.003906   255  0.003922
  1030309  10.041799    0  268     0      -inf   256  0.000000   256  0.003906
  1030310  10.118960    0  268     0       NaN     0      -inf   256  0.000000
  </code></pre>
  
  <p>I tried with the following</p>
  
  <pre><code>df.dropna(inplace=True)
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.40)
  
  X_train = X_train.drop('time', axis=1)
  X_train = X_train.drop('X_t1', axis=1)
  X_train = X_train.drop('X_t2', axis=1)
  X_test = X_test.drop('time', axis=1)
  X_test = X_test.drop('X_t1', axis=1)
  X_test = X_test.drop('X_t2', axis=1)
  X_test.fillna(X_test.mean(), inplace=True)
  X_train.fillna(X_train.mean(), inplace=True)
  y_train.fillna(y_train.mean(), inplace=True)
  </code></pre>
  
  <p>However, I am still getting this error <code>ValueError: Input contains NaN, infinity or a value too large for dtype('float32').</code> whenever i try to fit a regression model  <code>fit(X_train, y_train)</code></p>
  
  <p>How can we remove both the <code>NaN</code> and <code>-inf</code> values at the same time? </p>