title: Spark DataFrame operators (nunique, multiplication)
body: <p>I'm using jupyter notebook with pandas, but when i use Spark, i want to use Spark DataFrame to convert or computation instead of Pandas. Please help me convert some computation to Spark DataFrame or RDD.</p>
  
  <p>DataFrame:</p>
  
  <pre><code>df =
  +--------+-------+---------+--------+
  | userId | item  |  price  |  value |
  +--------+-------+---------+--------+
  |  169   | I0111 |  5300   |   1    |
  |  169   | I0973 |  70     |   1    |
  |  336   | C0174 |  455    |   1    |
  |  336   | I0025 |  126    |   1    |
  |  336   | I0973 |   4     |   1    |
  | 770963 | B0166 |   2     |   1    |
  | 1294537| I0110 |  90     |   1    |
  +--------+-------+---------+--------+
  </code></pre>
  
  <p><strong>1. Using Pandas computing:</strong> </p>
  
  <pre><code>(1)  userItem = df.groupby(['userId'])['item'].nunique()
  </code></pre>
  
  <p>and result is a Series object:</p>
  
  <pre><code>+--------+------+
  | userId |      |
  +--------+------+
  |  169   |   2  |
  |  336   |   3  |
  | 770963 |   1  |
  | 1294537|   1  |
  +--------+------+
  </code></pre>
  
  <p><strong>2. Using multiplication</strong></p>
  
  <pre><code>data_sum = df.groupby(['userId', 'item'])['value'].sum()  --&gt; result is Series object
  
  average_played = np.mean(userItem)  --&gt; result is number
  
  (2)  weighted_games_played = data_sum * (average_played / userItem)
  </code></pre>
  
  <p>Please help me using Spark DataFrame and Opertors on Spark to do this (1) and (2)</p>