Давайте разберемся с тем, где вы застряли:
# we get the keys from the first dict passed to the function
keys = list_dict[0].keys()
# we initialize a new dict where the definition for each key is an empty list
out_dict = {key:[] for key in keys }
for dict_ in list_dict:
# for each key in dict_ you append the value to the the list associated to this key in the out_dict
for key, value in dict_.items():
out_dict[key].append(value)
Фактически, этот фрагмент кода объединяет словари в list_dict в один для создания DataFrame. На самом деле это бесполезно, потому что pandas может создавать DataFrame прямо из списка словарей:
dict_1 = {'A': 22, 'B': 42}
dict_2 = {'A': 28, 'B': 1}
list_dict = [dict_1, dict_2]
df = pd.DataFrame(list_dict)