I have a dataframe with an array column like:
val df = Seq(
Array("abc", "abc", "null", "null"),
Array("bcd", "bc", "bcd", "null"),
Array("ijk", "abc", "bcd", "ijk")).toDF("col")
And looks like:
col:
["abc","abc","null","null"]
["bcd","bc","bcd","null"]
["ijk","abc","bcd","ijk"]
I am trying to get the duplicate value of each array in scala:
col_1:
['abc']
['bcd']
['ijk']
I tried to get the duplicate value in the list but no clue on how this can be done with array column
val df = List("bcd", "bc", "bcd", "null")
df.groupBy(identity).collect { case (x, List(_,_,_*)) => x }
explodethe array and then execute thegroupByas you already did