Using mongodb, I am outputting the unique field values and their number. Now I need to put this list in the ramp for further convenient work. But I don't quite understand how to do it because of the structure of the list.
unique_data = db.small_311.aggregate([
{'$group' : {'_id' : "$Complaint Type", 'uniqueCount' : {'$sum': 1}}}])
Part of the list
print(list(unique_data))
[{'_id': 'Posting Advertisement', 'uniqueCount': 5}, {'_id': 'APPLIANCE', 'uniqueCount': 445}, {'_id': 'Complaint', 'uniqueCount': 9},...]
I am trying to add to the dataframe
data_result = list(unique_data)
df = pd.DataFrame(data_result, columns =['Complaint Type', 'Value'])
df[:5]
But the result is an empty dataframe (it contains only the name of the fields, no data) Result dataframe