title: How to ensure get label for zero counts in python pandas pd.cut
body: <p>I am analyzing a DataFrame and getting timing counts which I want to put into specific buckets (0-10 seconds, 10-30 seconds, etc).</p>
  
  <p>Here is a simplified example:</p>
  
  <pre><code>import pandas as pd
  
  filter_values = [0, 10, 20, 30]  # Bucket Values for pd.cut
  
  #Sample Times
  df1 = pd.DataFrame([1, 3, 8, 20], columns  = ['filtercol'])
  
  #Use cut to get counts for each bucket
  out = pd.cut(df1.filtercol, bins = filter_values)
  counts = pd.value_counts(out)
  print counts
  </code></pre>
  
  <p>The above prints:</p>
  
  <pre><code>(0, 10]     3
  (10, 20]    1
  dtype: int64
  </code></pre>
  
  <p>You will notice it does not show any values for (20, 30].  This is a problem because I want to put this into my output as zero.  I can handle it using the following code:</p>
  
  <pre><code>bucket1=bucket2=bucket3=0
  if '(0, 10]' in counts: 
      bucket1=counts['(0, 10]']
  if '(10, 20]' in counts: 
      bucket2=counts['(10, 30]']
  if '(20, 30]' in counts: 
      bucket3=counts['(30, 60]']
  print bucket1, bucket2, bucket3
  </code></pre>
  
  <p>But I want a simpler cleaner approach where I can use:</p>
  
  <pre><code>print counts['(0, 10]'], counts['(10, 30]'], counts['(30, 60]']
  </code></pre>
  
  <p>Ideally where the print is based on the values in filter_values so they are only in one place in the code. Yes I know I can change the print to use filter_values[0]...</p>
  
  <p>Lastly when using cut is there a way to specify infinity so the last bucket is all values greater than say 60?</p>
  
  <p>Cheers,
  Stephen</p>