I have data in python where each row basically looks something like this:
{'touchdowns': 3, 'sport': 'Football', 'team: 'Cincinnati Bengals'}
I'm wondering whether the best way to store the data is with a list inside a dictionary, like this:
{
"points": [16, 2, 104],
"sport": ["Football", "Baseball", "Basketball"],
"team": ["Cincinnati Bengals", "New York Yankees", "LA Lakers"]
}
Or with a dictionary inside a list, like this:
[
{"points": 16, "sport": "Football", "team": "Cincinnati Bengals"},
{"points": 2, "sport": "Baseball", "team": "New York Yankees"},
{"points": 104, "sport": "Basketball", "team": "LA Lakers"}
]
A third option would be a dataframe in Pandas.
I'm going to use the data in something like this:
data = # either the list, dict, or df
new_data = get_new_data(x,y,z)
for row in new_data:
if row in data:
data.append(row)
# do other stuff to the row
else:
pass
So, what i'm trying to do is:
- Get a new row of data
- Check if the data is already in the dataset
- If it is, do nothing
- If it isn't, add it to the dataset and do other stuff to the row
Thanks for any and all help in advance!