title: Split column data based on Condition Pandas Dataframe
body: <p>I have a large data set and looking for something that will split my Street Address into two columns <code>Street Number</code> and <code>Street Name</code>. </p>
  
  <p>I am trying to figure out how can I do this efficiently since I first need to process the street address and then check if the first index of the split has a digit or not. </p>
  
  <p>So far I have a working code that looks like this. I created a two function one for extracting street number data from the street address, while the other one replaces the first occurrence of that street number from the street address. </p>
  
  <pre><code>def extract_street_number(row):
        if any(map(str.isdigit, row.split(" ")[0])):
          return row.split(" ")[0]
  
  
  def extract_street_name(address, streetnumber):
      if streetnumber:
          return address.replace(streetnumber, "", 1)
      else:
          return address
  </code></pre>
  
  <p>Then using the apply function to have the two columns.</p>
  
  <pre><code>df[street_number] = df.apply(lambda row: extract_street_number(row[address_col]), axis=1)
  df[street_name] = df.apply(lambda row: extract_street_name(row[address_col], row[street_number]), axis=1)
  </code></pre>
  
  <p>I'm wondering if there is a more efficient way to do this? Based on this current routine I need to build first the Street Number Column before I process the street name column. </p>
  
  <p>I'm thinking of something like building the two series on the first iteration of the address column. The pseudo-code is something like this I just can't figure it out how can I code it in python. </p>
  
  <p>Pseudocode:</p>
  
  <ol>
  <li><p>Split Address into two columns based on first space that encounters a non-numeric character: 
  <code>street_data = address.split(" ", maxsplit=1)</code></p></li>
  <li><p>If street_data[0] has digits then return the columns on this way: </p></li>
  </ol>
  
  <pre><code>      df[street_number] = street_data[0]
        df[street_name] = street_data[1]
  </code></pre>
  
  <ol start="3">
  <li>Else if street_data[0] is not digit then return the columns on this way:</li>
  </ol>
  
  <pre><code>      df[street_number] = ""
        df[street_name] = street_data[0] + " " + street_data[1]
        # or just simply the address
        df[street_name] = address
  </code></pre>
  
  <p>By the way this is the working sample of the data:</p>
  
  <pre><code># In
  df = pd.DataFrame({'Address':['111 Rubin Center', 'Monroe St', '513 Banks St', '5600 77 Center Dr', '1013 1/2 E Main St', '1234C Main St', '37-01 Fair Lawn Ave']})
  
  # Out
     Street_Number    Street_Name
  0           111     Rubin Center
  1                   Monroe St
  2           513     Banks St
  3        560 77     Center Dr
  4      1013 1/2     E Main St
  5         1234C     Main St
  6         37-01     Fair Lawn Ave
  </code></pre>