how to convert rows into columns in spark dataframe using scala [duplicate]

You can use pivot

val pivotDF = df.groupBy("GROUP").pivot("ITEM").first("AMOUNT")
pivotDF.show()

You can read more about pivot here https://databricks.com/blog/2016/02/09/reshaping-data-with-pivot-in-apache-spark.html