title: Pyspark Dataframe group by filtering
body: <p>I have a data frame as below</p>
  
  <pre><code>cust_id   req    req_met
  -------   ---    -------
   1         r1      1
   1         r2      0
   1         r2      1
   2         r1      1
   3         r1      1
   3         r2      1
   4         r1      0
   5         r1      1
   5         r2      0
   5         r1      1
  </code></pre>
  
  <p>I have to look at customers, see how many requirements they have and see if they have met at least once. There can be multiple records with same customer and requirement, one with met and not met. In the above case my output should be </p>
  
  <pre><code>cust_id
  -------
    1
    2
    3
  </code></pre>
  
  <p>What I have done is </p>
  
  <pre><code># say initial dataframe is df
  df1 = df\
      .groupby('cust_id')\
      .countdistinct('req')\
      .alias('num_of_req')\
      .sum('req_met')\
      .alias('sum_req_met')
  
  df2 = df1.filter(df1.num_of_req == df1.sum_req_met)
  </code></pre>
  
  <p>But in few cases it is not getting correct results</p>
  
  <p>How can this be done ?</p>