title: Keeping only one record from spark dataframe. Not necessary distinct record
body: <p>I have the following data:</p>
  
  <pre><code>id  type  price
  1    us    1.99
  1    ca    2.99
  2    ca    1.99
  3    au    2.99 
  3    us    3.99
  3    ca    2.99
  </code></pre>
  
  <p>Basically, I want to get only one record per <code>id</code> and if is more than one, then I want to keep one with type, <code>us</code> over others.</p>
  
  <p>Desired output:</p>
  
  <pre><code>id  type  price
  1    us    1.99
  2    ca    1.99
  3    us    3.99
  </code></pre>
  
  <p>How can I do this using either <code>PySpark</code> or <code>SparkSQL</code> against a <code>Spark DataFrame</code> or a table?</p>