Python 使用Dataframe to_string()方法时出现MemoryError

Python 使用Dataframe to_string()方法时出现MemoryError,python,pandas,dataframe,out-of-memory,Python,Pandas,Dataframe,Out Of Memory,我试图将目录结构中的文件列表读入pandas数据框,并希望在代码中以表格形式进行进一步处理 以下是我的代码: path = r'drive:\folder_1\folder_11\folder_111\folder_111\folder_1111\folder_11111\**\**\*.extension' # NOTE : This is just a representational path not a real-one. To give an idea what my director

我试图将目录结构中的文件列表读入pandas数据框,并希望在代码中以表格形式进行进一步处理

以下是我的代码:

path = r'drive:\folder_1\folder_11\folder_111\folder_111\folder_1111\folder_11111\**\**\*.extension'
# NOTE : This is just a representational path not a real-one. To give an idea what my directory structure of all files is like

# Reading all the files as csv and concatenate them into one dataframe   
df1 = pd.concat((pd.read_csv(f,sep='delimiter',engine='python') for f in glob.iglob(path, recursive=True)), ignore_index=True)

input = df1.to_string() # error line
print(input) 

但当我运行它时,这就是我在执行结束时得到的结果:

MemoryError
我也将此代码用于类似的数据文件,它在那里工作,但在本例中不起作用。此时,目录结构、文件类型都相同

有关更多上下文:

  • 要读取的数据帧非常大-[508785行x 4列]
  • 要读取的文件类型是.c扩展名-我正在尝试处理c源代码文件