title: Use python regex to replace dataframe column values with decimal part of string
body: <p>I have a dataframe with a column df['gravidityAndParity'] that contains string values like so:</p>
  <pre><code>0      g4p3
  1      g2p0
  2      g7p2
  3      g2p0
  4      g7p6
  </code></pre>
  <p>The number after 'g' is the gravidity and the number after 'p' is the parity. I am trying to split this column into two columns: df['gravidity'] and df['parity]</p>
  <p>So the output I am after is:</p>
  <pre class="lang-py prettyprint-override"><code>print(df['gravidity']) 
  </code></pre>
  <pre><code>0      4
  1      2
  2      7
  3      2
  4      7
  </code></pre>
  <pre class="lang-py prettyprint-override"><code>print(df['parity])
  </code></pre>
  <pre><code>0      3
  1      0
  2      2
  3      0
  4      6
  </code></pre>
  <p>I defined a function using regex to do this, but the function is not working correctly.</p>
  <p>Here is my code so far:</p>
  <pre class="lang-py prettyprint-override"><code>
  import regex as re 
    
  # Function to clean the names
  def Split_gravidity_parity(gravidityAndParity):
      match_gravidity = re.search('g(\d+)', gravidityAndParity)
      if match_gravidity:
          df['gravidity']= match_gravidity.group(1)
          
      match_parity = re.search('p(\d+)', gravidityAndParity)
      if match_parity:
          df['parity']= match_parity.group(1) 
  </code></pre>
  <p>Applying the function to the column:</p>
  <pre class="lang-py prettyprint-override"><code>
  df['gravidityAndParity'].apply(Split_gravidity_parity)
  
  print(df['gravidity'])
  </code></pre>
  <pre><code>0      4
  1      4
  2      4
  3      4
  4      4
  </code></pre>
  <pre class="lang-py prettyprint-override"><code>print(df['parity'])
  </code></pre>
  <pre><code>0      3
  1      3
  2      3
  3      3
  4      3
  </code></pre>
  <p>The function seems to be partially working, as it only seems to be applied to the first value in the column 'g4p3'.</p>
  <p>Any help with how I can implement this regex function correctly to all values in the column and output the results in two new columns 'gravidity' and 'parity'?</p>