我的代码在pandas中正常运行,但在modin中没有

2024-09-27 04:21:36 发布

您现在位置:Python中文网/ 问答频道 /正文

当我使用pandas时,代码运行得很好(但是非常慢), 当使用modin和concat dataframe时,会显示一个错误

contador = 0
df = pd.DataFrame()
data = pd.DataFrame()

for file in range(len(files)):
    usefile = files[file]
    print("Valor Numero :" + str(contador) + " de un total de " + str((len(files))) + " archivos")
    print("Existe " + str(usefile) + " añadiendolo al DataFrame" )
    contador = contador +1
    ruta = mainpath + "/" + str(usefile) 
    df = pd.read_csv(ruta)
    datos[usefile] = df
data = pd.concat(datos.values(), keys=datos.keys() , sort='True')

我希望输出一个数据帧,其中所有文件都从dict连接,但是y receive(在pandas中,一切都很完美):

^{pr2}$

Tags: dataframepandasdfdatalendefilesfile
1条回答
网友
1楼 · 发布于 2024-09-27 04:21:36

基于keys和{}参数可订阅的假设,Modin(版本0.4)无意中还不支持这种行为。在

在Modin中修复代码的最后一行之前,可以更改代码中的最后一行作为解决方法:

data = pd.concat(list(datos.values()), keys=list(datos.keys()) , sort='True')

我在Modin repo上创建了一个问题来跟踪问题:https://github.com/modin-project/modin/issues/557

相关问题 更多 >

    热门问题