我的json如下所示:
json_obj=[{'extracted_value':{'other':'Not found','sound':'false','longterm':'false','Medicine':'false','false','page_num':'33','score':'0.75','number':12223611,'misc':'true'}]
df=pd.DataFrame(json_obj)[['extracted_value','page_num','conf_score','number']
我只提取上述信息。但现在我想忽略“other”:“notfound”在extracted_value列中,然后像上面的值一样提取
您可以尝试
df['extracted_value'].apply(remove_other)
,即对列提取的值应用函数完整代码为:
结果将是:
其他答复:
df['extracted_value'].apply(remove_other)
表示列值将作为参数传递给函数。您可以将print语句print(my_dict)
放在remove_other
中以更好地可视化它可以更改代码以从和条件中删除字典值
我建议您熟悉JSON。在这种情况下,需要转到[0]['coord'][0]。因此,函数将类似于:
相关问题 更多 >
编程相关推荐