我在Python中使用Pandas获取导入.csv文件的DataFrame。现在,DataFrame有多个列,其中一些列具有int或string数据,而其他列具有Json数据。 例如:在Pandas Python中清洁DataFrame字段
AA A B \
40.0 90.0 {"0": 5.5815269769616, "1": 5.7224734728583, "...
我有多行,但为了简单起见我在它刚刚过去。
现在,我想删除“B”内的括号和所有的东西报价之间,并且也具有条目数组或列表。 基本上,这应该是结果:
AA A B \
40.0 90.0 [5.5815269769616,5.7224734728583,3.4456]
在此先感谢
你可以使用'df.B.apply(some_function) ',其中'some_function'解析json字符串,并为您提供所需的输出。 –