[英]Write output of pandas.io.parsers.TextFileReader to pandas.DataFrame
[英]Problem reading a data from a file with pandas Python (pandas.io.parsers.TextFileReader)
我想用 pandas 從文件中讀取數據集,但是當我使用 pd.read_csv() 時,程序會讀取它,但是當我想查看數據幀時:
pandas.io.parsers.TextFileReader 位於 0x1b3b6b3e198
作為附加信息,文件太大(大約 9 Gigas)
該文件使用垂直線作為分隔符,我嘗試使用 chunksize 但它不起作用。
import pandas as pd
df = pd.read_csv(r"C:\Users\dguerr\Documents\files\Automotive\target_file", iterator=True, sep='|',chunksize=1000)
我想以傳統的熊貓數據框格式導入我的數據。
您可以通過以下方式按塊加載塊:
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
它可能與unicode編碼有關嗎?
import pandas as pd
df = pd.read_csv('C:/Users/dguerr/Documents/Acxiom files/Automotive/auto_model_target_file',
encoding='latin-1', chunksize=1000)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.