title: Scala- How to do GroupBy and Sum on case class?
body: <p>I'm fairly new to this.. My problem is: for a case class <code>case class testclass(date_key: String , amount: Int, type:String, condition1:String, condition2: String)</code></p>
  
  <p>In <code>Dataframe df</code>, I'm trying to sum the <code>amount</code>, groupby it by <code>type:String</code>, when a row's <code>condition1=condition2</code></p>
  
  <p>I'm trying to define a function but how should I do this? Many thanks! </p>
  
  <pre><code> `def sumAmount (t: testclass): Int = { 
        if (condition1==condition2) 
     {
  
     } else {
         "na"
     }
    }`
  </code></pre>