title: Python Replacing missing values
body: <p>I am trying to replace missing values in a specific column in a dataframe, but having some issues.
  Have tried:</p>
  <pre><code>from sklearn.impute import SimpleImputer
  fill_0_with_mean = SimpleImputer(missing_values=0, strategy='mean')
  X_train['Age'] = fill_0_with_mean.fit_transform(X_train['Age'])
  </code></pre>
  <p>and</p>
  <pre><code>X_train[:,15] = fill_0_with_mean.fit_transform(X_train[:,15])
  </code></pre>
  <p>and</p>
  <pre><code>X_train[:,15:16] = fill_0_with_mean.fit_transform(X_train[:,15:16])
  </code></pre>
  <p>and</p>
  <pre><code>X_train['Age'] = fill_0_with_mean.fit_transform(X_train['Age'].values)
  </code></pre>
  <p>and</p>
  <pre><code>X_train[:,15:16] = fill_0_with_mean.fit_transform(X_train[:,15:16].values)
  </code></pre>
  <p>But I keep getting errors around
  <strong>ValueError: Input contains NaN, infinity or a value too large for dtype('float64').</strong> or <strong>IndexError: only integers, slices (<code>:</code>), ellipsis (<code>...</code>), numpy.newaxis (<code>None</code>) and integer or boolean arrays are valid indices</strong></p>
  <p>I have zero and missing (NaN) values in my data. Can the imputer only do one of the two? How do I go about doing this?
  I have also tried casting my age column as an integer</p>
  <pre><code>X_train['Age'] = X_train['Age'].as_type('int32')
  </code></pre>
  <p>But this just gives me other errors.</p>
  <p>my data looks like (the Age column)</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th></th>
  <th>Age</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>0</td>
  <td>31.0</td>
  </tr>
  <tr>
  <td>1</td>
  <td>79.0</td>
  </tr>
  <tr>
  <td>2</td>
  <td>53.0</td>
  </tr>
  <tr>
  <td>3</td>
  <td>40.0</td>
  </tr>
  <tr>
  <td>4</td>
  <td>55.0</td>
  </tr>
  <tr>
  <td></td>
  <td>...</td>
  </tr>
  <tr>
  <td>44872</td>
  <td>NaN</td>
  </tr>
  <tr>
  <td>44873</td>
  <td>NaN</td>
  </tr>
  <tr>
  <td>44874</td>
  <td>NaN</td>
  </tr>
  <tr>
  <td>44875</td>
  <td>NaN</td>
  </tr>
  <tr>
  <td>44876</td>
  <td>NaN</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Is it possible that numpy and pandas are getting mixed up? I used this to split my data into training and testing:</p>
  <pre><code>from sklearn.model_selection import train_test_split
  
  dep_var = ['is_overdue']
  features = model_data2.columns
  features = features.drop(dep_var)
  
  print(features)
  
  X = model_data2[features].values
  Y = model_data2[dep_var].values
  
  split_test_size = 0.30
  
  X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=split_test_size, random_state=42) 
  </code></pre>
  <p>I'd greatly appreciate the help.</p>