嵌套列表中的嵌套字典到 Dataframe

时间:2021-06-29 16:01:39

标签: python-3.x pandas dataframe

我想要一个使用以下数据的数据框:

有人能帮我解决这个问题吗,我已经尝试了好几天了。

[['Asturias', {'Keyword': 'gato', 'Related queries rising': {'query': 'No data', 'value': 0}, 'Related queries top': [{'query': 'el gato negro oviedo', 'value': 100}], 'Related topics rising': [{'value': 131050, 'formattedValue': 'Breakout', 'link': '/trends/explore?q=/m/041ztf&date=today+1-m&geo=ES-AS', 'topic_mid': '/m/041ztf', 'topic_title': 'Scratching post', 'topic_type': 'Topic'}], 'Related topics top': [{'value': 100, 'formattedValue': '100', 'hasData': True, 'link': '/trends/explore?q=/m/01yrx&date=today+1-m&geo=ES-AS', 'topic_mid': '/m/01yrx', 'topic_title': 'Cat', 'topic_type': 'Animal'}, {'value': 6, 'formattedValue': '6', 'hasData': True, 'link': '/trends/explore?q=/m/041ztf&date=today+1-m&geo=ES-AS', 'topic_mid': '/m/041ztf', 'topic_title': 'Scratching post', 'topic_type': 'Topic'}]}, {'Keyword': 'perro', 'Related queries rising': [{'query': 'regalo perro asturias', 'value': 26100}], 'Related queries top': [{'query': 'regalo perro asturias', 'value': 100}], 'Related topics rising': [{'value': 80, 'formattedValue': '+80%', 'link': '/trends/explore?q=/m/0bt9lr&date=today+1-m&geo=ES-AS', 'topic_mid': '/m/0bt9lr', 'topic_title': 'Dog', 'topic_type': 'Animal'}], 'Related topics top': [{'value': 100, 'formattedValue': '100', 'hasData': True, 'link': '/trends/explore?q=/m/0bt9lr&date=today+1-m&geo=ES-AS', 'topic_mid': '/m/0bt9lr', 'topic_title': 'Dog', 'topic_type': 'Animal'}, {'value': 3, 'formattedValue': '3', 'hasData': True, 'link': '/trends/explore?q=/m/09lkz&date=today+1-m&geo=ES-AS', 'topic_mid': '/m/09lkz', 'topic_title': 'Adoption', 'topic_type': 'Topic'}]}],['Aragon', {'Keyword': 'gato', 'Related queries rising': {'query': 'No data', 'value': 0}, 'Related queries top': {'query': 'No data', 'value': 0}, 'Related topics rising': [], 'Related topics top': [{'value': 100, 'formattedValue': '100', 'hasData': True, 'link': '/trends/explore?q=/m/01yrx&date=today+1-m&geo=ES-AR', 'topic_mid': '/m/01yrx', 'topic_title': 'Cat', 'topic_type': 'Animal'}]}, {'Keyword': 'perro', 'Related queries rising': {'query': 'No data', 'value': 0}, 'Related queries top': {'query': 'No data', 'value': 0}, 'Related topics rising': [{'value': 40, 'formattedValue': '+40%', 'link': '/trends/explore?q=/m/0kpmf&date=today+1-m&geo=ES-AR', 'topic_mid': '/m/0kpmf', 'topic_title': 'Dog breed', 'topic_type': 'Topic'}], 'Related topics top': [{'value': 100, 'formattedValue': '100', 'hasData': True, 'link': '/trends/explore?q=/m/0bt9lr&date=today+1-m&geo=ES-AR', 'topic_mid': '/m/0bt9lr', 'topic_title': 'Dog', 'topic_type': 'Animal'}, {'value': 10, 'formattedValue': '10', 'hasData': True, 'link': '/trends/explore?q=/m/01yrx&date=today+1-m&geo=ES-AR', 'topic_mid': '/m/01yrx', 'topic_title': 'Cat', 'topic_type': 'Animal'}, {'value': 5, 'formattedValue': '5', 'hasData': True, 'link': '/trends/explore?q=/m/0kpmf&date=today+1-m&geo=ES-AR', 'topic_mid': '/m/0kpmf', 'topic_title': 'Dog breed', 'topic_type': 'Topic'}]}],['Catalonia', {'Keyword': 'gato', 'Related queries rising': [{'query': 'gato de pallas', 'value': 22450}], 'Related queries top': [{'query': 'gato de pallas', 'value': 100}, {'query': 'gato egipcio', 'value': 100}], 'Related topics rising': [{'value': 47900, 'formattedValue': 'Breakout', 'link': '/trends/explore?q=/m/0j60j&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0j60j', 'topic_title': 'Maine Coon', 'topic_type': 'Cat breed'}, {'value': 47850, 'formattedValue': 'Breakout', 'link': '/trends/explore?q=/m/01p1s6&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01p1s6', 'topic_title': "Pallas's cat", 'topic_type': 'Animal'}, {'value': 47800, 'formattedValue': 'Breakout', 'link': '/trends/explore?q=/m/0492nq&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0492nq', 'topic_title': 'Cat food', 'topic_type': 'Topic'}, {'value': 23850, 'formattedValue': 'Breakout', 'link': '/trends/explore?q=/m/076yn_b&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/076yn_b', 'topic_title': 'Pet carrier', 'topic_type': 'Topic'}, {'value': 140, 'formattedValue': '+140%', 'link': '/trends/explore?q=/m/031n1&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/031n1', 'topic_title': 'Foot', 'topic_type': 'Topic'}, {'value': 100, 'formattedValue': '+100%', 'link': '/trends/explore?q=/m/053jb&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/053jb', 'topic_title': 'Month', 'topic_type': 'Unit of time'}, {'value': 80, 'formattedValue': '+80%', 'link': '/trends/explore?q=/m/01szky&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01szky', 'topic_title': 'Climbing shoe', 'topic_type': 'Topic'}, {'value': 80, 'formattedValue': '+80%', 'link': '/trends/explore?q=/m/0g_3r&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0g_3r', 'topic_title': 'Siamese cat', 'topic_type': 'Cat breed'}], 'Related topics top': [{'value': 100, 'formattedValue': '100', 'hasData': True, 'link': '/trends/explore?q=/m/01yrx&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01yrx', 'topic_title': 'Cat', 'topic_type': 'Animal'}, {'value': 5, 'formattedValue': '5', 'hasData': True, 'link': '/trends/explore?q=/m/053jb&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/053jb', 'topic_title': 'Month', 'topic_type': 'Unit of time'}, {'value': 3, 'formattedValue': '3', 'hasData': True, 'link': '/trends/explore?q=/m/0g_3r&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0g_3r', 'topic_title': 'Siamese cat', 'topic_type': 'Cat breed'}, {'value': 3, 'formattedValue': '3', 'hasData': True, 'link': '/trends/explore?q=/m/01szky&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01szky', 'topic_title': 'Climbing shoe', 'topic_type': 'Topic'}, {'value': 2, 'formattedValue': '2', 'hasData': True, 'link': '/trends/explore?q=/m/0j60j&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0j60j', 'topic_title': 'Maine Coon', 'topic_type': 'Cat breed'}, {'value': 2, 'formattedValue': '2', 'hasData': True, 'link': '/trends/explore?q=/m/01p1s6&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01p1s6', 'topic_title': "Pallas's cat", 'topic_type': 'Animal'}, {'value': 2, 'formattedValue': '2', 'hasData': True, 'link': '/trends/explore?q=/m/0492nq&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0492nq', 'topic_title': 'Cat food', 'topic_type': 'Topic'}, {'value': 2, 'formattedValue': '2', 'hasData': True, 'link': '/trends/explore?q=/m/031n1&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/031n1', 'topic_title': 'Foot', 'topic_type': 'Topic'}, {'value': 2, 'formattedValue': '2', 'hasData': True, 'link': '/trends/explore?q=/m/03dj64&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/03dj64', 'topic_title': 'Black cat', 'topic_type': 'Topic'}, {'value': 1, 'formattedValue': '1', 'hasData': True, 'link': '/trends/explore?q=/m/012qjw&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/012qjw', 'topic_title': 'Vomiting', 'topic_type': 'Ailment'}, {'value': 1, 'formattedValue': '1', 'hasData': True, 'link': '/trends/explore?q=/m/06hdcj&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/06hdcj', 'topic_title': 'Race', 'topic_type': 'Biology'}, {'value': 1, 'formattedValue': '1', 'hasData': True, 'link': '/trends/explore?q=/m/076yn_b&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/076yn_b', 'topic_title': 'Pet carrier', 'topic_type': 'Topic'}, {'value': 1, 'formattedValue': '1', 'hasData': True, 'link': '/trends/explore?q=/m/0j46v&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0j46v', 'topic_title': 'Persian cat', 'topic_type': 'Cat breed'}, {'value': 1, 'formattedValue': '1', 'hasData': True, 'link': '/trends/explore?q=/g/121rvmg6&date=today+1-m&geo=ES-CT', 'topic_mid': '/g/121rvmg6', 'topic_title': 'Sandpit', 'topic_type': 'Topic'}]}, {'Keyword': 'perro', 'Related queries rising': [{'query': 'dieta barf perro', 'value': 13350}, {'query': 'perro salchicha', 'value': 50}], 'Related queries top': [{'query': 'perro de agua', 'value': 100}], 'Related topics rising': [{'value': 42050, 'formattedValue': 'Breakout', 'link': '/trends/explore?q=/m/0c673&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0c673', 'topic_title': 'Dream', 'topic_type': 'Topic'}, {'value': 27850, 'formattedValue': 'Breakout', 'link': '/trends/explore?q=/m/01hsr_&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01hsr_', 'topic_title': 'Sneeze', 'topic_type': 'Topic'}, {'value': 27850, 'formattedValue': 'Breakout', 'link': '/trends/explore?q=/m/01jpqs&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01jpqs', 'topic_title': 'Healing', 'topic_type': 'Topic'}, {'value': 14000, 'formattedValue': 'Breakout', 'link': '/trends/explore?q=/g/122z_qxw&date=today+1-m&geo=ES-CT', 'topic_mid': '/g/122z_qxw', 'topic_title': 'Firecracker', 'topic_type': 'Topic'}, {'value': 13900, 'formattedValue': 'Breakout', 'link': '/trends/explore?q=/m/03_7wn&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/03_7wn', 'topic_title': 'Pointer', 'topic_type': 'Dog breed'}, {'value': 13850, 'formattedValue': 'Breakout', 'link': '/trends/explore?q=/m/02xrl&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/02xrl', 'topic_title': 'Fear', 'topic_type': 'Topic'}, {'value': 13750, 'formattedValue': 'Breakout', 'link': '/trends/explore?q=/m/01t49s&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01t49s', 'topic_title': 'Courage the Cowardly Dog', 'topic_type': 'American animated series'}, {'value': 13700, 'formattedValue': 'Breakout', 'link': '/trends/explore?q=/m/09v1cn&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/09v1cn', 'topic_title': 'Ratonero Bodeguero Andaluz', 'topic_type': 'Dog breed'}, {'value': 450, 'formattedValue': '+450%', 'link': '/trends/explore?q=/m/012qjw&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/012qjw', 'topic_title': 'Vomiting', 'topic_type': 'Ailment'}, {'value': 250, 'formattedValue': '+250%', 'link': '/trends/explore?q=/m/035r7c&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/035r7c', 'topic_title': 'Leg', 'topic_type': 'Topic'}, {'value': 200, 'formattedValue': '+200%', 'link': '/trends/explore?q=/m/071jj&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/071jj', 'topic_title': 'Siberian Husky', 'topic_type': 'Dog breed'}, {'value': 200, 'formattedValue': '+200%', 'link': '/trends/explore?q=/m/0k0pj&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0k0pj', 'topic_title': 'Nose', 'topic_type': 'Topic'}, {'value': 60, 'formattedValue': '+60%', 'link': '/trends/explore?q=/m/03241&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/03241', 'topic_title': 'Feces', 'topic_type': 'Topic'}, {'value': 60, 'formattedValue': '+60%', 'link': '/trends/explore?q=/m/01y029&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01y029', 'topic_title': 'Herder', 'topic_type': 'Topic'}, {'value': 60, 'formattedValue': '+60%', 'link': '/trends/explore?q=/m/06hdcj&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/06hdcj', 'topic_title': 'Race', 'topic_type': 'Biology'}], 'Related topics top': [{'value': 100, 'formattedValue': '100', 'hasData': True, 'link': '/trends/explore?q=/m/0bt9lr&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0bt9lr', 'topic_title': 'Dog', 'topic_type': 'Animal'}, {'value': 8, 'formattedValue': '8', 'hasData': True, 'link': '/trends/explore?q=/m/0kpmf&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0kpmf', 'topic_title': 'Dog breed', 'topic_type': 'Topic'}, {'value': 7, 'formattedValue': '7', 'hasData': True, 'link': '/trends/explore?q=/m/06hdcj&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/06hdcj', 'topic_title': 'Race', 'topic_type': 'Biology'}, {'value': 4, 'formattedValue': '4', 'hasData': True, 'link': '/trends/explore?q=/m/035r7c&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/035r7c', 'topic_title': 'Leg', 'topic_type': 'Topic'}, {'value': 3, 'formattedValue': '3', 'hasData': True, 'link': '/trends/explore?q=/m/012qjw&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/012qjw', 'topic_title': 'Vomiting', 'topic_type': 'Ailment'}, {'value': 3, 'formattedValue': '3', 'hasData': True, 'link': '/trends/explore?q=/g/1q6jyh33m&date=today+1-m&geo=ES-CT', 'topic_mid': '/g/1q6jyh33m', 'topic_title': 'compound feed', 'topic_type': 'Topic'}, {'value': 2, 'formattedValue': '2', 'hasData': True, 'link': '/trends/explore?q=/m/01llwg&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01llwg', 'topic_title': 'Necklace', 'topic_type': 'Topic'}, {'value': 2, 'formattedValue': '2', 'hasData': True, 'link': '/trends/explore?q=/m/0c673&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0c673', 'topic_title': 'Dream', 'topic_type': 'Topic'}, {'value': 2, 'formattedValue': '2', 'hasData': True, 'link': '/trends/explore?q=/g/1q6j9v4vp&date=today+1-m&geo=ES-CT', 'topic_mid': '/g/1q6j9v4vp', 'topic_title': 'Ixodoidea', 'topic_type': 'Animal'}, {'value': 2, 'formattedValue': '2', 'hasData': True, 'link': '/trends/explore?q=/m/03241&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/03241', 'topic_title': 'Feces', 'topic_type': 'Topic'}, {'value': 2, 'formattedValue': '2', 'hasData': True, 'link': '/trends/explore?q=/m/0271kpq&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0271kpq', 'topic_title': 'Spanish Water Dog', 'topic_type': 'Dog breed'}, {'value': 2, 'formattedValue': '2', 'hasData': True, 'link': '/trends/explore?q=/m/01y029&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01y029', 'topic_title': 'Herder', 'topic_type': 'Topic'}, {'value': 2, 'formattedValue': '2', 'hasData': True, 'link': '/trends/explore?q=/m/071jj&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/071jj', 'topic_title': 'Siberian Husky', 'topic_type': 'Dog breed'}, {'value': 2, 'formattedValue': '2', 'hasData': True, 'link': '/trends/explore?q=/m/0k0pj&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/0k0pj', 'topic_title': 'Nose', 'topic_type': 'Topic'}, {'value': 1, 'formattedValue': '1', 'hasData': True, 'link': '/trends/explore?q=/m/01hsr_&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01hsr_', 'topic_title': 'Sneeze', 'topic_type': 'Topic'}, {'value': 1, 'formattedValue': '1', 'hasData': True, 'link': '/trends/explore?q=/m/01jpqs&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01jpqs', 'topic_title': 'Healing', 'topic_type': 'Topic'}, {'value': 1, 'formattedValue': '1', 'hasData': True, 'link': '/trends/explore?q=/g/122z_qxw&date=today+1-m&geo=ES-CT', 'topic_mid': '/g/122z_qxw', 'topic_title': 'Firecracker', 'topic_type': 'Topic'}, {'value': 1, 'formattedValue': '1', 'hasData': True, 'link': '/trends/explore?q=/m/03_7wn&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/03_7wn', 'topic_title': 'Pointer', 'topic_type': 'Dog breed'}, {'value': 1, 'formattedValue': '1', 'hasData': True, 'link': '/trends/explore?q=/m/02xrl&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/02xrl', 'topic_title': 'Fear', 'topic_type': 'Topic'}, {'value': 1, 'formattedValue': '1', 'hasData': True, 'link': '/trends/explore?q=/m/01t49s&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/01t49s', 'topic_title': 'Courage the Cowardly Dog', 'topic_type': 'American animated series'}, {'value': 1, 'formattedValue': '1', 'hasData': True, 'link': '/trends/explore?q=/m/09v1cn&date=today+1-m&geo=ES-CT', 'topic_mid': '/m/09v1cn', 'topic_title': 'Ratonero Bodeguero Andaluz', 'topic_type': 'Dog breed'}]}]]

预期输出是一个国家不同位置的表格。在每个位置内,我都希望有一个带有“关键字”的列。对于每个“关键字”,我希望“相关查询上升”(“查询”和“值”)“相关查询顶部”(“查询”和“值”)和相关主题上升(“topic_title”,“ topic_type', 'value') 和 '相关主题 top' ('topic_title', 'topic_type', 'value')。但也在不同的细胞中。 “查询”单元格和“值”单元格。

我不知道如何处理嵌套列和嵌套行..

0 个答案:

没有答案