Python中增加进度条tqdm

from tqdm import tqdm

# 循环中使用进度条
for i in tqdm(range(10000)):
	pass

# pandas中使用进度条
tqdm.pandas()
df['var_new'] = df['var'].progress_apply(lambda x: x**x)

tqdm对pandas中的apply()过程提供了特殊的支持,因为pandas中的apply()本质上就是串行循环运算,你可以将pandas中的任何apply操作替换为progress_apply,并且记住每个单独的progress_apply前要先执行tqdm.pandas()

posted @ 2022-05-19 20:37  EconCoder  阅读(5)  评论(0)    收藏  举报