我有一个如下所示的数据框(列名 - 日期、错误消息、消息)
data = """Date|Error|message
26/11/19 | unauthorized access | {"eventVersion":"1.05","userIdentity":"type":"IAMUser","principalId":"AIDAIETZDDDVS36MMCHPS","arn":"arn:aws:iam::819490967212:user/IAMAdmin","accountId":"819490967212","accessKeyId":"ASIA35TLXZ2WPIBTBWP2","userName":"IAMAdmin","sessionContext":{"sessionIssuer":{},"webIdFederationData":{},"attributes":{"mfaAuthenticated":"false","creationDate":"2019-12-19T03:14:04Z"}}"""
from io import StringIO
df = pd.read_csv(StringIO(data),sep='|)
print(df)
Date Error message
0 26/11/19 unauthorized access {"eventVersion":"1.05","userIdentity":"type":...
消息列的每一行都有类似json格式的数据。
如何从“消息”列中检索某些键及其各自的值("userName", "account ID"),以便这些键可以成为新列。
尝试使用 python 但无法检索
森栏
慕码人8056858
相关分类