title: How to create bins on a column in a data frame
body: <p>I have a data frame df with structure like so:</p>
  
  <p><strong>Input</strong></p>
  
  <pre><code>amount id
  13000  1
  30000  2
  10000  3
  5000   4
  </code></pre>
  
  <p>I want to create a new column which based on the quantiles of column 'amount'</p>
  
  <p><strong>Expected Output:</strong></p>
  
  <pre><code>amount id amount_bin
  13000  1  10000
  30000  2  15000
  10000  3  10000
  5000   4  5000
  </code></pre>
  
  <p>Assume the qualities 0.25, 0.5 and 0.75 are 5000, 10000 and 15000 respectively</p>
  
  <p>I know how to do this in R:</p>
  
  <pre><code>quantile &lt;- quantile(df$amount, probs = c(0, 0.25, 0.50, 0.75, 1.0), na.rm = TRUE, 
                       names = FALSE)
  
  df$amount_bin &lt;- cut(df$amount, breaks = quantile, include.lowest = TRUE, 
                       labels = c(quantile[2], quantile[3], quantile[4], quantile[5]))
  </code></pre>