I have the following dataframe
+---+-----+-------+---+
| id|state|country|zip|
+---+-----+-------+---+
| 1| AAA | USA|123|
| 2| XXX | CHN|234|
| 3| AAA | USA|123|
| 4| PPP | USA|222|
| 5| PPP | USA|222|
| 5| XXX | CHN|234|
+---+-----+-------+---+
I want to create a flat dataframe with arrays for count of each distinct value in each column, something as follows:
+-------------------------+--------------------+------------------------+
|state |country |zip |
+-------------------------+--------------------+------------------------+
|[[AAA, 2],[PPP,2][XXX,2]]|[[USA, 4],[CHN,123]]|[123, 2],[234,2][222,2]]|
+-------------------------+--------------------+------------------------+
Original table has 600+ columns but my aim is to do this for columns which only contain less than 100 unique values in total.