当我使用 pandas 时,代码运行良好(但非常慢),当使用 modin 和 concat 数据帧时,显示错误
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 接收(在 pandas 中,一切都很完美):
<ipython-input-4-e5a361476e76> in <module>
12 df = pd.read_csv(ruta)
13 datos[usefile] = df
---> 14 data = pd.concat(datos.values(), keys=datos.keys() , sort='True')
15
~/anaconda3/lib/python3.7/site-packages/modin/pandas/concat.py in concat(objs, axis, join, join_axes, ignore_index, keys, levels, names, verify_integrity, sort, copy)
98 new_idx_labels = {
99 keys[i]: objs[i].index if axis == 0 else objs[i].columns
--> 100 for i in range(len(objs))
101 }
102 print(new_idx_labels)
~/anaconda3/lib/python3.7/site-packages/modin/pandas/concat.py in <dictcomp>(.0)
98 new_idx_labels = {
99 keys[i]: objs[i].index if axis == 0 else objs[i].columns
--> 100 for i in range(len(objs))
101 }
102 print(new_idx_labels)
TypeError: 'dict_keys' object is not subscriptable