I want to convert a Spark DataFrame into another DataFrame with a specific manner as follows:
I have Spark DataFrame:
+---------+------------+
|protocol | count |
+---------+------------+
| TCP| 8231 |
| ICMP| 7314 |
| UDP| 5523 |
| IGMP| 4423 |
| EGP| 2331 |
+---------+------------+
And I want to turn it into:
+----------------------------------------------------------+
|Aggregated |
+----------------------------------------------------------+
|{tcp: 8231, icmp: 7314, udp: 5523, igmp: 4423, egp: 2331} |
+----------------------------------------------------------+
The aggregated column can be both list or map, or string. Is this possible with DataFrame functions or do I need to create my own udf to aggregate this ?