'Dataframe from list of list of dicts

I searched the website but nothing really matches.

I have an example data:

data_2 = [[{'url':'http://url1.com', 'traffic':810}], [{'url':'http://url2.com', 'traffic':811}]] 

How to create a dataframe from that so that the output would look like this:


                             url traffic
0                 http://url1.com  810
1                 http://url2.com  811

I tried:

import pandas as pd

data_2 = [[{'url':'http://url1.com', 'traffic':810}], [{'url':'http://url2.com', 'traffic':811}]] 

df2 = pd.DataFrame(data = data_2, columns = ['url', 'traffic'])
print(df2)


but received a "ValueError: 2 columns passed, passed data had 1 columns"



Sources

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

Source: Stack Overflow

Solution Source