我正在读取一个.parquet文件,其中包含以下字符串列:
{"circuitStatus": "CREATED", "startedAt": "2019-02-11T16:07:31.121Z",
"event": "CIRCUIT_CREATION"},
{"circuitStatus": "RUNNING", "startedAt": "2019-02-11T16:07:32.147Z",
"diff": [], "event": "CIRCUIT_UPDATED"}]}
我想取消此列的注释,但它失败了,因为它是一个字符串。你知道吗
这是原始数据帧:
我手动完成了Jupyter笔记本中最不寻常的部分:
df =pd.concat([df.drop(['B'], axis=1), df['B'].apply(pd.Series)], axis=1)
但仅当列不是字符串时:
df = pd.DataFrame({'A':'7e1ab727-a9e9-4c00-b6dc-9e65e91b9e4f','B':[{"circuitStatus": "CREATED", "startedAt": "2019-02-11T16:07:31.121Z", "event": "CIRCUIT_CREATION"}, {"circuitStatus": "RUNNING", "startedAt": "2019-02-11T16:07:32.147Z", "diff": [], "event": "CIRCUIT_UPDATED"}]})
df2 = pd.DataFrame({'A':'22222222-a9e9-4c00-b6dc-9e65e91b9e4f','B':[{"circuitStatus": "CREATED",` "startedAt": "2019-02-11T16:07:31.121Z", "event": "CIRCUIT_CREATION"}, {"circuitStatus": "RUNNING", "startedAt": "2019-02-11T16:07:32.147Z", "diff": [], "event": "CIRCUIT_UPDATED"}]})
df3 = pd.concat([df, df2])
df3 =pd.concat([df3.drop(['B'], axis=1), df3['B'].apply(pd.Series)], axis=1)
df3
当我尝试从.parquet读取相同的代码时,它不会抛出错误,但最不必要的是它没有完成
目前没有回答
相关问题 更多 >
编程相关推荐