为什么在将 json 转换为 python 中的数据帧后,我只收到 1 行数据?

Why do I only receive 1 row of data after converting json to dataframe in python?

我的剧本-

from azure.cosmos import CosmosClient
import os
import pandas as pd
url = "https://xx-cosmos-dev.xx.azure.com:xx/"
key = 'xx=='
client = CosmosClient(url, credential=key)
database_name = 'ClS'
database = client.get_database_client(database_name)
container_name = 'cls'
container = database.get_container_client(container_name)

# Enumerate the returned items
import json
for item in container.query_items(query='SELECT * FROM c',enable_cross_partition_query=True):
    print(json.dumps(item, indent=True))

输出:

    {
       "IncidentId": null,
       "IncidentType": "Illness",
       "SymptomStartDate": "4/5/2022",
       "SubDiagnosisIds": [
        155
       ]
      }
     ],
     "_rid": "xx==",
     "_self": "dbs/Cb04AA==/colls/xx=/docs/Cb04ALkCaPhsAwAAAAAAAA==/",
     "_etag": "\"2600f2cf-0000-0400-0000-xxx\"",
     "_attachments": "attachments/",
     "_ts": xxxx
    }
    {
     "IsServiceSubCodeToSubDiagnosisRule": false,
     "IsSubDiagnosisRule": false,
     "IsClaimSubmission": true,
     "id": "xxxx",
     "partitionKey": "Submission",
     "term": xx,
     "got": xx,
     "IsMultiInvoce": false,
     "AutomationIncidents": no

我试过了-

dflist = []
dflist.append(dict(item))  
# Convert list to pandas DataFrame
df = pd.DataFrame(dflist)

但是我只收到1行数据。我有大约 300 rows.Why 它不是全部捕获吗?我是否必须向追加项目功能添加一些内容?

谢谢,Tranbi and Joe Tha。将对话要点添加为社区 Wiki 答案以帮助其他社区成员。

代替此代码:

dflist = []
dflist.append(dict(item))  
# Convert list to pandas DataFrame
df = pd.DataFrame(dflist)

尝试使用此代码获取多行:

dflist = []
for item in container.query_items(query='SELECT * FROM c',enable_cross_partition_query=True):
    dflist.append(dict(item))
df = pd.DataFrame(dflist)