title: Add leading zeros based on condition in python
body: <p>I have a dataframe with 5 million rows. Let's say the dataframe looked like below:</p>
  
  <pre><code>&gt;&gt;&gt; df = pd.DataFrame(data={"Random": "86 7639103627 96 32 1469476501".split()})
  &gt;&gt;&gt; df
         Random
  0          86
  1  7639103627
  2          96
  3          32
  4  1469476501
  </code></pre>
  
  <p>Note that the <code>Random</code> column is stored as a string. </p>
  
  <p>If the number in column Random has fewer than 9 digits, I want to add leading zeros to make it 9 digits. If the number has 9 or more digits, I want to add leading zeros to make it 20 digits.</p>
  
  <p>what I have done is this:</p>
  
  <pre><code>for i in range(0,len(df['Random'])):
        if len(df['Random'][i]) &lt; 9:
            df['Random'][i]=df['Random'][i].zfill(9)
        else:
             df['Random'][i]=df['Random'][i].zfill(20)
  </code></pre>
  
  <p>Since the number of rows is over 5 million, this process takes a lot of time! (performance was 5it/sec. Tested using tqdm, estimated time of completion was in days!). </p>
  
  <p>Is there an easier and faster way of performing this task?</p>