本文整理汇总了Python中bamboo.models.observation.Observation.batch_read_dframe_from_cursor方法的典型用法代码示例。如果您正苦于以下问题:Python Observation.batch_read_dframe_from_cursor方法的具体用法?Python Observation.batch_read_dframe_from_cursor怎么用?Python Observation.batch_read_dframe_from_cursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bamboo.models.observation.Observation
的用法示例。
在下文中一共展示了Observation.batch_read_dframe_from_cursor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dframe
# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import batch_read_dframe_from_cursor [as 别名]
def dframe(self, query_args=None, keep_parent_ids=False, padded=False,
index=False, reload_=False, keep_mongo_keys=False):
"""Fetch the dframe for this dataset.
:param query_args: An optional QueryArgs to hold the query arguments.
:param keep_parent_ids: Do not remove parent IDs from the dframe,
default False.
:param padded: Used for joining, default False.
:param index: Return the index with dframe, default False.
:param reload_: Force refresh of data, default False.
:param keep_mongo_keys: Used for updating documents, default False.
:returns: Return DataFrame with contents based on query parameters
passed to MongoDB. DataFrame will not have parent ids if
`keep_parent_ids` is False.
"""
# bypass cache if we need specific version
cacheable = not (query_args or keep_parent_ids or padded)
# use cached copy if we have already fetched it
if cacheable and not reload_ and self.__is_cached:
return self.__dframe
query_args = query_args or QueryArgs()
observations = self.observations(query_args, as_cursor=True)
if query_args.distinct:
return DataFrame(observations)
dframe = Observation.batch_read_dframe_from_cursor(
self, observations, query_args.distinct, query_args.limit)
dframe = df_mongo_decode(dframe, keep_mongo_keys=keep_mongo_keys)
excluded = [keep_parent_ids and PARENT_DATASET_ID, index and INDEX]
dframe = remove_reserved_keys(dframe, filter(bool, excluded))
if index:
dframe.rename(columns={INDEX: 'index'}, inplace=True)
dframe = self.__maybe_pad(dframe, padded)
if cacheable:
self.__dframe = dframe
return dframe