PandasDataFrame中的.json文件:“非类型”对象没有属性“键”

2024-05-20 17:59:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在处理一些以.json格式保存的研究结果文件。 但是,我可以使用教程在Python Pandas中与其中一些人一起工作,如下所示:

file = open(path, 'r')
    meta_df = pd.read_json(file)

对另一个.json使用相同的方法会产生:

AttributeError: 'NoneType' object has no attribute 'keys'

.json看起来像:

[
{
"reference": null,
"enter_app": 1603456818731,
"dummy1": 1603456925901,
"dummy2": 1603456971867,
"start_time": 1603456828542,
"end_time": null,
"entered_link": null,
"start_task": null,
"end_task": null,
"start_task2": null,
"end_task2": null,
"End_begin": null,
"End_end": null
 },
{
"test_version": "7",
"component_id": "10",
"ResultId": "2222",
"Id": "2",
"device": "desktop",
"operatingSystem": "Linux OS",
"link": "00000000",
"browser": "BrowserName = Chrome\nVersion = 80.0.3987.163",
"language": "de",
"age": null,
"gender": null
},
{
"baseline": {
  "1": 33,
  "2": 19,
  "3": 36,
  "4": 4
 },
"intermediate": {
  "1": null,
  "2": null,
  "3": null,
  "4": null
 },
"post": {
  "1": null,
  "2": null,
  "3": null,
  "4": null
 }
},
{
"begin_p": null,
"end_p": null
}
]

你知道吗? 似乎和.json的结构有关,对吗?但由于所有参与者都是这样保存的,我想


Tags: 文件jsonpandastasktime格式link教程