Assume I have multiple lists of dict's, something along the lines of
list_one = [{'genre': 'Action', 'amount': 141, 'meanScore': 82}, {'genre': 'Comedy', 'amount': 191, 'meanScore': 82}]
list_two = [{'genre': 'Horror', 'amount': 11, 'meanScore': 62}, {'genre': 'Comedy', 'amount': 191, 'meanScore': 82}]
My goal is to write this to a file in the form
Action Comedy Horror
list_one meanScore meanScore
amount amount
list_two meanScore meanScore
amount amount
I'm not really familiar with dict and what the best way is to store them, but it seems that csv- files are quite popular for that. I tried to use this answer here to solve my problem, but I'm having difficulty in understanding what @MarkLongair does and how you would expand that to my problem. One of the main things that concerns me is that not every genre is part of every list, so I don't know how to check in the existing csv file if the key exists, where it is located and how to write the value into the right column.
Since I couldn't really understand the linked answer I tried something along the lines of
from pandas import DataFrame
list_one = [{'genre': 'Action', 'amount': 141, 'meanScore': 82},
{'genre': 'Comedy', 'amount': 191, 'meanScore': 82}]
list_two = [{'genre': 'Horror', 'amount': 11, 'meanScore': 62},
{'genre': 'Comedy', 'amount': 191, 'meanScore': 82}]
DataFrame(list_one).to_csv('test.csv')
DataFrame(list_two).to_csv('test.csv')
which doesn't really work since the data get's overwritten and the things I wanted to be the columns get transformed to rows...
I'm not sure how to go on form here or what exactly the right direction is... Can somebody maybe help a bit?