Consider the following dataframe:

```
------------+--------------------+
|id|          values
+------------+--------------------+
|          39|a,a,b,b,c,c,c,c,d
|         520|a,b,c
|         832|a,a

```

I want to convert it into the following DataFrame:

```
------------+--------------------+
|id|          values
+------------+--------------------+
|          39|{"a":2, "b": 2,"c": 4,"d": 1}
|         520|{"a": 1,"b": 1,"c": 1}
|         832|{"a": 2}

```

I tried two approaches:

1. Converting the dataframe to rdd. Then I mapped the value column to a frequancy counter function. But I get errors on converting the rdd back to the dataframe
2. Using a udf to essentially do the same thing as above.

The reason I want to have a dictionary column is to load it as a json in one of my python application.