栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

熊猫行动中的进度指示器

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

熊猫行动中的进度指示器

由于需求旺盛,我

pandas
tqdm
pip install "tqdm>=4.9.0"
)中添加了支持。与其他答案不同,这
不会明显降低熊猫的速度 -这是以下示例
DataframeGroupBy.progress_apply

import pandas as pdimport numpy as npfrom tqdm import tqdm# from tqdm.auto import tqdm  # for notebooksdf = pd.Dataframe(np.random.randint(0, int(1e8), (10000, 1000)))# Create and register a new `tqdm` instance with `pandas`# (can use tqdm_gui, optional kwargs, etc.)tqdm.pandas()# Now you can use `progress_apply` instead of `apply`df.groupby(0).progress_apply(lambda x: x**2)

如果您对它的工作方式(以及如何为自己的回调进行修改)感兴趣,请参阅github上的示例,pypi上的完整文档或导入模块并运行

help(tqdm)
。其它支持的功能包括
map
applymap
aggregate
,和
transform

编辑


要直接回答原始问题,请替换为:

df_users.groupby(['userID', 'requestDate']).apply(feature_rollup)

与:

from tqdm import tqdmtqdm.pandas()df_users.groupby(['userID', 'requestDate']).progress_apply(feature_rollup)

注意:tqdm <= v4.8:对于低于4.8的tqdm版本,

tqdm.pandas()
您不必执行以下操作:

from tqdm import tqdm, tqdm_pandastqdm_pandas(tqdm())


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/626419.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号