title: python pandas if statement based on len
body: <p>This code gives me the following dataframe:</p>
  
  <pre><code>import pandas as pd
  
  pace=['06:40','10:05','7:25','10:30']
  distance=['10','20','30','40']
  dd=list(zip(pace,distance))
  df=pd.DataFrame(dd,columns=['pace','distance'])
  
      pace    distance
  0  06:40       10
  1  10:05       20
  2   7:25       30
  3  10:30       40
  </code></pre>
  
  <p>If I try to parse the pace data that is less the 11:00 with the following code I get:</p>
  
  <pre><code>input='11:00'
  length_input=len(input)
  df=df[df['pace']&lt;input]
  
     pace    distance
  0  06:40       10
  1  10:05       20
  3  10:30       40
  </code></pre>
  
  <p>I would like to be able to add a zero to the beginning of all pace data that has a len==4 so that any pace value like 7:25 is included.  I've tried the following code:</p>
  
  <pre><code>if df['pace'].astype(str).map(len)==4:
      df['pace']='0'+df['pace'].astype(str)
  </code></pre>
  
  <p>This code results in the error - ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().</p>
  
  <p>After searching this error I've found documentation for or(|) and and(&amp;).  Any help would be greatly appreciated.</p>