title: How compute the percentile in PySpark dataframe for each key?
body: <p>I have a PySpark dataframe consists of three columns x, y, z.</p>
  <p>X may have multiple rows in this dataframe. How can I compute the percentile of each key in x separately?</p>
  <pre class="lang-none prettyprint-override"><code>+------+---------+------+
  |  Name|     Role|Salary|
  +------+---------+------+
  |   bob|Developer|125000|
  |  mark|Developer|108000|
  |  carl|   Tester| 70000|
  |  carl|Developer|185000|
  |  carl|   Tester| 65000|
  | roman|   Tester| 82000|
  | simon|Developer| 98000|
  |  eric|Developer|144000|
  |carlos|   Tester| 75000|
  | henry|Developer|110000|
  +------+---------+------+
  </code></pre>
  <p>The output needed:</p>
  <pre class="lang-none prettyprint-override"><code>+------+---------+------+---------+
  |  Name|     Role|Salary|      50%|
  +------+---------+------+---------+
  |   bob|Developer|125000|117500.0 |
  |  mark|Developer|108000|117500.0 |
  |  carl|   Tester| 70000|72500.0  |
  |  carl|Developer|185000|117500.0 |
  |  carl|   Tester| 65000|72500.0  |
  | roman|   Tester| 82000|72500.0  |
  | simon|Developer| 98000|117500.0 |
  |  eric|Developer|144000|117500.0 |
  |carlos|   Tester| 75000|72500.0  |
  | henry|Developer|110000|117500.0 |
  +------+---------+------+---------+
  </code></pre>