title: replacing string with a different string in pandas depending on value
body: <p>I am practicing pandas and I have an exercise with which I have a problem</p>
  <p>I have an excel file that has a column where two types of urls are stored.</p>
  <pre><code>df = pd.DataFrame({'id': [], 
                     'url': ['www.something/12312', 'www.something/12343', 'www.somethingelse/42312', 'www.somethingelse/62343']})
  </code></pre>
  <pre><code>   | id | url |
      | -------- | -------------- |
      |     | 'www.something/12312'  |
      |   | 'www.something/12343'    |
      |     | 'www.somethingelse/42312'    | 
      |    | 'www.somethingelse/62343'    | 
  </code></pre>
  <p>I am supposed to transform this into ids, but only number should be part of the id, the new id column should look like this:</p>
  <pre><code>df = pd.DataFrame({'id': [id_12312 , id_12343, diffid_42312, diffid_62343], 'url': ['www.something/12312', 'www.something/12343', 'www.somethingelse/42312', 'www.somethingelse/62343']})
  </code></pre>
  <pre><code>| id | url |
  | -------- | -------------- |
  | id_12312    | 'www.something/12312'  |
  | id_12343    | 'www.something/12343'    |
  | diffid_42312    | 'www.somethingelse/42312'    | 
  | diffid_62343    | 'www.somethingelse/62343'    | 
  </code></pre>
  <p>My problem is how to get only numbers and replace them if that kind of id?
  I have tried the replace and extract function in pandas</p>
  <pre><code>id_replaced = df.replace(regex={re.search('something', df['url']): 'id_' + str(re.search(r'\d+', i).group()), re.search('somethingelse', df['url']): 'diffid_' + str(re.search(r'\d+', i).group())})
          
  df['id'] = df['url'].str.extract(re.search(r'\d+', df['url']).group())
  </code></pre>
  <p>However, they are throwing an error TypeError: expected string or bytes-like object.</p>
  <p>Sorry for the tables in codeblock. The page was screaming that I have code that is not properly formatted when it was not in a codeblock.</p>