可以将tqdm用于 pandas 合并操作吗? [英] Is it possible to use tqdm for pandas merge operation?

查看:59
本文介绍了可以将tqdm用于 pandas 合并操作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以找到tqdm进度条用于group by和其他熊猫操作的示例.但是在合并或连接上找不到任何东西.

I could find examples of tqdm progress bar being used for group by and other pandas operations. But couldn't find anything on merge or join.

是否可以在熊猫上使用tqdm进行合并?

Is it possible to use tqdm on pandas for merge ?

推荐答案

tqdm支持熊猫及其内部的各种操作.为了合并两个大型数据框并显示进度,您可以通过以下方式做到这一点:

tqdm supports pandas and various operations within it. For merging two large dataframes and showing the progress, you could do it this way:

import pandas as pd
from tqdm import tqdm

df1 = pd.DataFrame({'lkey': 1000*['a', 'b', 'c', 'd'],'lvalue': np.random.randint(0,int(1e8),4000)})
df2 = pd.DataFrame({'rkey': 1000*['a', 'b', 'c', 'd'],'rvalue': np.random.randint(0, int(1e8),4000)})

#this is how you activate the pandas features in tqdm
tqdm.pandas()
#call the progress_apply feature with a dummy lambda 
df1.merge(df2, left_on='lkey', right_on='rkey').progress_apply(lambda x: x)

有关此线程的更多详细信息: 熊猫操作期间的进度指示器(python)

More details are available on this thread: Progress indicator during pandas operations (python)

这篇关于可以将tqdm用于 pandas 合并操作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆