title: How to get a new dataframe which only 10 lines per user_id(column name)?
body: <p>I have a dataframe that looks like: </p>
  
  <pre><code> scala&gt; df.show()
   +-------+-------+                                                               
   |user_id|book_id|
   +-------+-------+
   | 235610|2757548|
   | 235610|2352922|
   | 235610| 620968|
   | 235610|1037143|
   | 235610|2319578|
   |   ... | ....  |
   | 235610|1037143|
   | 235610|2319578|
  </code></pre>
  
  <p>and it`s have three different users in the "user_id" column as follows :</p>
  
  <pre><code>scala&gt; val df1 = df.select("user_id").distinct()
  scala&gt; df1.show()
  +-------+                                                                       
  |user_id|
  +-------+
  | 235610|
  | 211065|
  | 211050|
  +-------+
  </code></pre>
  
  <p>Number of lines per <code>user("235610","211065","21050")</code> as follows:</p>
  
  <pre><code>scala&gt; df.filter($"user_id"==="235610").count()
  res28: Long = 140  
  
  scala&gt; df.filter($"user_id"==="211065").count()
  res29: Long = 51
  
  scala&gt; df.filter($"user_id"==="211050").count()
  res30: Long = 64
  </code></pre>
  
  <p>Now my problem is how to get a new dataframe which only 10 lines per user_id? Because every <code>user_id("235610","211065","21050")</code> is over 10 records per user.</p>
  
  <p>Spark version 2.3.0. Any help will be appreciated.</p>