Python 使用tqdm将熊猫移动到\u csv进度条

Python 使用tqdm将熊猫移动到\u csv进度条,python,pandas,tqdm,Python,Pandas,Tqdm,正如标题所示,我试图在执行pandas.to_csv时显示进度条 我有以下脚本: def filter_pileup(pileup, output, lists): tqdm.pandas(desc='Reading, filtering, exporting', bar_format=BAR_DEFAULT_VIEW) # Reading files pileup_df = pd.read_csv(pileup, '\t', header=None).progress_

正如标题所示,我试图在执行
pandas.to_csv
时显示进度条
我有以下脚本:

def filter_pileup(pileup, output, lists):
    tqdm.pandas(desc='Reading, filtering, exporting', bar_format=BAR_DEFAULT_VIEW)
    # Reading files
    pileup_df = pd.read_csv(pileup, '\t', header=None).progress_apply(lambda x: x)
    lists_df = pd.read_csv(lists, '\t', header=None).progress_apply(lambda x: x)
    # Filtering pileup
    intersection = pd.merge(pileup_df, lists_df, on=[0, 1]).progress_apply(lambda x: x)
    intersection.columns = [i for i in range(len(intersection.columns))]
    intersection = intersection.loc[:, 0:5]
    # Exporting filtered pileup
    intersection.to_csv(output, header=None, index=None, sep='\t')

在前几行中,我找到了一种集成进度条的方法,但这种方法对最后一行不起作用,我如何才能实现这一点?

以一种非常粗糙的方式,您可以创建一个包装类,该类继承自
io.TextIOBase
周围的
输出
。编写
调用到
输出
,更新进度条时。但我不推荐,所以我不会把它作为答案发布。你找到解决方案了吗?如果您能将其作为答案发布,我将不胜感激:)@Sierox我还没有找到解决这个确切问题的方法,但最终,我使用了dask模块,该模块本身在
dask.diagnostics