For a sample dataframe scholor
,
scala> scholor.show
| id| name|age|sal|base|
For above, both below, gives same output. What will be use of agg() then. It just for name.
scala> scholor.groupBy("age").sum("base").show /*with out agg */
scala> scholor.groupBy("age").agg(sum("base")).show /* with agg */
+---+---------+
|age|sum(base)|
+---+---------+
Does agg()
need any varargs as arguments?
What is need of agg()
?
Thanks in advance.
In order write .sum
this method has to exist. It is hardcoded on the API. Using .agg
you can provide other aggregating functions, sum("column")
is just one of them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With