[英]Is there a more efficient way to interact with ItemPaged objects from azure-data-tables SDK function query_entities?
The quickest method I have found is to just convert the ItemPaged object to a list using list() and then I'm able to manipulate/extract using a Pandas DataFrame. However, if I have millions of results, the process can be quite time-consuming, especially if I only want every nth result over a certain time-frame, for instance.我发现最快的方法是使用 list() 将 ItemPaged object 转换为列表,然后我可以使用 Pandas DataFrame 进行操作/提取。但是,如果我有数百万个结果,这个过程可能会很长- 消耗,特别是如果我只想要特定时间范围内的每第 n 个结果,例如。 Typically, I would have to query the entire time-frame and then re-loop to only obtain every nth element.通常,我必须查询整个时间范围,然后重新循环以仅获取每个第 n 个元素。 Does anyone know a more efficient way to use query_entities OR how to more efficiently return every nth item from ItemPaged or more explicitly from table.query_entities?有谁知道使用 query_entities 的更有效方法或如何更有效地从 ItemPaged 或更明确地从 table.query_entities 返回每第 n 个项目? Portion of my code below:我的代码部分如下:
connection_string = "connection string here"
service = TableServiceClient.from_connection_string(conn_str=connection_string)
table_string = ""
table = service.get_table_client(table_string)
entities = table.query_entities(filter, select, etc.)
results = pd.DataFrame(list(entities))
Does anyone know a more efficient way to use query_entities OR how to more efficiently return every nth item from ItemPaged or more explicitly from table.query_entities?有谁知道使用 query_entities 的更有效方法或如何更有效地从 ItemPaged 或更明确地从 table.query_entities 返回每第 n 个项目?
After reproducing from my end, one of the ways to achieve your requirement using get_entity()
instead of query_entities()
.从我这边复制后,使用get_entity()
而不是query_entities()
) 来实现您的要求的方法之一。 Below is the complete code that worked for me.以下是对我有用的完整代码。
entity = tableClient.get_entity(partition_key='<PARTITION_KEY>', row_key='<ROW_KEY>')
print("Results using get_entity :")
print(format(entity))
RESULTS:结果:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.