title: Replace specific value in pandas dataframe column, else convert column to numeric
body: <p>Given the following pandas dataframe</p>
  
  <pre><code>+----+------------------+-------------------------------------+--------------------------------+
  |    |   AgeAt_X        |   AgeAt_Y                           |   AgeAt_Z                      |
  |----+------------------+-------------------------------------+--------------------------------+
  |  0 |   Older than 100 |                      Older than 100 |                          74.13 |
  |  1 |              nan |                                 nan |                          58.46 |
  |  2 |              nan |                                 8.4 |                          54.15 |
  |  3 |              nan |                                 nan |                          57.04 |
  |  4 |              nan |                               57.04 |                            nan |
  +----+------------------+-------------------------------------+--------------------------------+
  </code></pre>
  
  <p>how can I replace values in specific columns which equal <code>Older than 100</code> with <code>nan</code></p>
  
  <pre><code>+----+------------------+-------------------------------------+--------------------------------+
  |    |   AgeAt_X        |   AgeAt_Y                           |   AgeAt_Z                      |
  |----+------------------+-------------------------------------+--------------------------------+
  |  0 |              nan |                                 nan |                          74.13 |
  |  1 |              nan |                                 nan |                          58.46 |
  |  2 |              nan |                                 8.4 |                          54.15 |
  |  3 |              nan |                                 nan |                          57.04 |
  |  4 |              nan |                               57.04 |                            nan |
  +----+------------------+-------------------------------------+--------------------------------+
  </code></pre>
  
  <p><strong>Notes</strong></p>
  
  <ul>
  <li>After removing the <code>Older than 100</code> string from the desired columns, I convert the columns to numeric in order to perform calculations on said columns.</li>
  <li>There are other columns in this dataframe (that I have excluded from this example), which will not be converted to numeric, so the conversion to numeric must be done one column at a time. </li>
  </ul>
  
  <p><strong>What I've tried</strong></p>
  
  <p><strong>Attempt 1</strong></p>
  
  <pre><code>if df.isin('Older than 100'):
      df.loc[df['AgeAt_X']] = ''
  else:
      df['AgeAt_X'] = pd.to_numeric(df["AgeAt_X"])
  </code></pre>
  
  <p><strong>Attempt 2</strong></p>
  
  <pre><code>if df.loc[df['AgeAt_X']] == 'Older than 100r':
      df.loc[df['AgeAt_X']] = ''
  elif df.loc[df['AgeAt_X']] == '':
      df['AgeAt_X'] = pd.to_numeric(df["AgeAt_X"])
  </code></pre>
  
  <p><strong>Attempt 3</strong></p>
  
  <pre><code>df['AgeAt_X'] = ['' if ele == 'Older than 100' else df.loc[df['AgeAt_X']] for ele in df['AgeAt_X']]
  </code></pre>
  
  <p>Attempts 1, 2 and 3 return the following error:</p>
  
  <p><code>KeyError: 'None of [0      NaN\n1      NaN\n2      NaN\n3      NaN\n4      NaN\n5      NaN\n6      NaN\n7      NaN\n8      NaN\n9      NaN\n10     NaN\n11     NaN\n12     NaN\n13     NaN\n14     NaN\n15     NaN\n16     NaN\n17     NaN\n18     NaN\n19     NaN\n20     NaN\n21     NaN\n22     NaN\n23     NaN\n24     NaN\n25     NaN\n26     NaN\n27     NaN\n28     NaN\n29     NaN\n        ..\n6332   NaN\n6333   NaN\n6334   NaN\n6335   NaN\n6336   NaN\n6337   NaN\n6338   NaN\n6339   NaN\n6340   NaN\n6341   NaN\n6342   NaN\n6343   NaN\n6344   NaN\n6345   NaN\n6346   NaN\n6347   NaN\n6348   NaN\n6349   NaN\n6350   NaN\n6351   NaN\n6352   NaN\n6353   NaN\n6354   NaN\n6355   NaN\n6356   NaN\n6357   NaN\n6358   NaN\n6359   NaN\n6360   NaN\n6361   NaN\nName: AgeAt_X, Length: 6362, dtype: float64] are in the [index]'</code></p>
  
  <p><strong>Attempt 4</strong></p>
  
  <pre><code>df['AgeAt_X'] = df['AgeAt_X'].replace({'Older than 100': ''})
  </code></pre>
  
  <p>Attempt 4 returns the following error:</p>
  
  <p><code>TypeError: Cannot compare types 'ndarray(dtype=float64)' and 'str'</code></p>
  
  <p>I've also looked at a few posts. The two below do not actually replace the value but create a new column derived from others</p>
  
  <p><a href="https://stackoverflow.com/questions/49557895/replace-specific-values-in-pandas-dataframe/49558169#49558169">Replace specific values in Pandas DataFrame</a></p>
  
  <p><a href="https://stackoverflow.com/questions/55342023/pandas-replace-dataframe-values">Pandas replace DataFrame values</a></p>