I have a .txt file, named 'data.txt' which is a list of dictionaries, i.e., something like,
{"958464": ["item1", "item3"], "917654": [], "1347584": ["item2", "item5", "item6", "item7"], "914082": [], "946178": ["item1", "item4", "item15"], ...}
How can form a dataframe, with the above file?
My idea is cross information (about ID) with another database, so I think form dataframe like,
ID ITEMS
0 958464 "item1", "item3"
1 917654
2 1347584 "item2", "item5", "item6", "item7"
3 914082
4 946178 "item1", "item3", "item5"
...
Or maybe, create a dataframe like
ID Item1 item2 item3 ...
0 958464 1 0 1
1 917654 0 0 0
2 1347584 0 1 0
3 914082 0 0 0
4 946178 1 0 1
...
I tried
data = pd.read_csv('data1.txt')
pd.DataFrame(data.items())