如下所示:
def read_data(file_name): \'\'\' file_name:文件地址 \'\'\' inputfile = open(file_name, \'rb\') #可打开含有中文的地址 data = pd.read_csv(inputfile, iterator=True) loop = True chunkSize = 1000 #一千行一块 chunks = [] while loop: try: chunk = dcs.get_chunk(chunkSize) chunks.append(chunk) except StopIteration: loop = False print(\"Iteration is stopped.\") data = pd.concat(chunks, ignore_index=True) #print(train.head()) return data
以上这篇python分块读取大数据,避免内存不足的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
继续阅读与本文标签相同的文章
-
阿里云注册域名教程
2026-05-19栏目: 教程
-
程序员开发工具大全
2026-05-19栏目: 教程
-
开箱即用-OSS无代理备份
2026-05-19栏目: 教程
-
RDS MySQL 8.0 Returning
2026-05-19栏目: 教程
-
阿里云智能大学训练营讲师培训
2026-05-19栏目: 教程
