[英]How to extract text from nested list in python and put in column?
This is the first observation.这是第一个观察。 I need these all in different columns instead of the same column.
我需要这些都在不同的列而不是同一列。
[{'route': 'Oral',
'brand_name': 'MSK',
'active_ingredients': [{'dose': {'denominator_unit': 'Unknown',
'numerator': '1',
'numerator_unit': 'Unknown',
'denominator': '1'},
'name': 'Diethylcarbamazine, Oxibendazole'}],
'atc_vet_code': 'QP52AC57',
'dosage_form': 'Tablet',
'manufacturer': {'registration_number': 'USA-USFDACVM-N136483',
'name': 'MSK'}}]
I want the result to look something like this.我希望结果看起来像这样。
route![]() |
brand name![]() |
active_ingredients![]() |
brand name![]() |
atc_vet_code ![]() |
dosage_form'![]() |
---|---|---|---|---|---|
oral![]() |
MSK![]() |
Diethylcarbamazine, Oxibendazole![]() |
QP52AC57 ![]() |
tablet![]() |
You might want to check out the answer here Convert list of dictionaries to a pandas DataFrame您可能想在此处查看答案将字典列表转换为 pandas DataFrame
The relevant answer is the one talking about json_normalize
.相关的答案是关于
json_normalize
的答案。 https://stackoverflow.com/a/53831756/381179 https://stackoverflow.com/a/53831756/381179
A list of nested dicts is pretty much what the json data format would look like, and rather than writing some custom read-in functionality, you can use what's already there嵌套字典列表几乎就是 json 数据格式的样子,而不是编写一些自定义读入功能,您可以使用已经存在的内容
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.