I have a Pandas/PySpark dataframe like this.
I want to convert this into the below format.
Tried using PySpark with below code
df2 = df.groupBy('id').agg( F.to_json( F.collect_list( F.create_map( 'Details','Values' ) ) ).alias('Attributes'))
df2.show(truncate=False)