我想用 pandas 从文件中读取数据集,但是当我使用 pd.read_csv() 时,程序会读取它,但是当我想看到数据框出现时:
pandas.io.parsers.TextFileReader 位于 0x1b3b6b3e198
作为附加信息,文件太大(大约 9 GB)
该文件使用垂直线作为分隔符,我尝试使用 chunksize 但它不起作用。
import pandas as pd
df = pd.read_csv(r"C:\Users\dguerr\Documents\files\Automotive\target_file", iterator=True, sep='|',chunksize=1000)
我想以传统的 pandas 数据帧格式导入数据。
最佳答案
您可以通过执行以下操作逐 block 加载它:
import pandas as pd
path_to_file = "C:/Users/dguerr/Documents/Acxiom files/Automotive/auto_model_target_file"
chunk_size = 1000
for chunk in pd.read_csv(path_to_file,chunksize=chunk_size):
# do your stuff
关于python - 使用 pandas Python (pandas.io.parsers.TextFileReader) 从文件读取数据时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56704836/