[Solved] How to add columns using Scala
val grouped = df.groupBy($”id”).count val res = df.join(grouped,Seq(“id”)) .withColumnRenamed(“count”,”repeatedcount”) Group By will give count of each id’s. Join that with original dataframe to get count against each id. solved How to add columns using Scala