from pathos.multiprocessing import ThreadPool
# create a thread pool with the max number of threads
tPool = ThreadPool()
# apply the same function to each df
# the function applies to your list of dataframes
newDFs = tPool.map(lambda df: df.reindex(newIndex),dfs)
是的,您的解决方案是好的,只需通过列表理解将其分配给新的
list of DataFrame
:很好的解决方案,建议@Joe Halliwell,谢谢:
^{pr2}$或者像suggest@roganjosh一样,可以创建数据帧字典:
^{3}$然后按键选择每个数据帧:
样本:
或者:
如果有很多大数据帧,可以使用多个线程。我建议使用pathos模块(可以使用pip install pathos安装):
相关问题 更多 >
编程相关推荐