title: Make Bins in pyspark with range of values and specific values
body: <p>I want to make bins on a pyspark dataframe column with range of values and specific values</p>
  <p>In this post <a href="https://stackoverflow.com/questions/46225587/how-to-bin-in-pyspark">How to bin in PySpark?</a> It explains how yo make the bins, but it is only for range of values, from 0 to 6, from 6 to 18, and so on, I would like to have just a bin for specific values, for example, I want bins from 0 to 5, 5 to 9, 10, 11 to 20, 21 and more</p>
  <pre><code>+-----------+
  | Age | Bin |
  +-----------+
  |  4  |  1  |
  | 10  |  3  |
  |  6  |  2  |
  | 40  |  5  |
  |  2  |  1  |
  |  8  |  2  |
  +-----------+
  </code></pre>
  <p>I tried</p>
  <pre><code>splits = [ 0, 5, 9, 10, 10, 11, float('Inf') ]
  </code></pre>
  <p>But It gives an error</p>
  <p>I used a tolerance to make the bin just for 10, but I am wondering if there is a better way</p>
  <pre><code>tol= 1.0e-10
  splits = [ 0, 5, 9, 10, 10+tol, 11, float('Inf') ]
  </code></pre>