'how to create a dataframe from a list of dictionary value?

I have a list -

elements_listed = [{'data': {'data/2022/04/1': '26-Apr-2022 07:47', 'data/2022/04/2': '24-Apr-2022 17:27', 'data/2022/04/3': '22-Apr-2022 14:20'}}, {'data': {'data/2022/03/1': '31-Mar-2022 21:55', 'data/2022/03/2': '30-Mar-2022 03:54'}}}]

I want a dataframe from this list with two columns -

links                                                                   date
data/2022/04/1          26-Apr-2022 07:47
data/2022/04/2         24-Apr-2022 17:27
data/2022/04/3          22-Apr-2022 14:20
data/2022/03/1          31-Mar-2022 21:55
data/2022/03/2          30-Mar-2022 03:54

Any help would be appreciated in creating this dataframe from this list?



Solution 1:[1]

You can check concat

import pandas as pd

out = pd.concat(pd.Series(x['data']) for x in elements_listed).reset_index()
out.columns = ['links','date']

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 L D