Pandas support reading straight from a list of dicts like this.
list1 = [dict1, dict2, dict3]
df = pd.DataFrame(list1)
Using that you can later select a column using:
column = df["column_name"]
If you want a non pandas way you can do this:
list1 = [dict1, dict2, dict3]
columns = {}
# Initializing the keywords
for d in list1:
for k in d:
if k not in columns:
columns[k] = []
for d in list1:
for k in columns:
if k in d:
columns[k].append(d[k])
else:
# because you want all columns to have the same length
columns[k].append(None)
print(columns)
EDIT: This script unpacks the "events_list" column to a new dataframe with the given blueprint described by the OP.
import pandas as pd
import ast
df = pd.read_csv("Sampleofuefa.csv")
l = []
for d in df["events_list"]:
# the values in the columns are strings, you have to interpret them
# since ast.literal_eval returns a list of dicts, we extend the following
# list with that list of dict: l = l1 + l2
l.extend(ast.literal_eval(d))
event_df = pd.DataFrame(l)