腌制一个DataFrame [英] Pickling a DataFrame
问题描述
我正在尝试用...腌制一个DataFrame
I am trying to pickle a DataFrame with
import pandas as pd
from pandas import DataFrame
data = pd.read_table('Purchases.tsv',index_col='coreuserid')
data.to_pickle('Purchases.pkl')
我已经在数据"上运行了一段时间,没有任何问题,所以我知道这不是数据损坏问题.我正在考虑可能的语法,但是我尝试了多种变体.我犹豫要给出整个错误消息,但它的结尾是:
I have been running on "data" for a while and have had no issues so I know it is not a data corruption issue. I am thinking likely syntax but I have tried a number of variants. I hesitate to give the whole error message but it ends with:
\pickle.pyc in to_pickle(obj, path)
13 """
14 with open(path, 'wb') as f:
15 pkl.dump(obj, f, protocol=pkl.HIGHEST_PROTOCOL)
SystemError: error return without exception set
创建了Purchases.pkl文件,但如果我打电话
The Purchases.pkl file is created but if I call
data = pd.read_pickle('Purchases.pkl')
我收到EOFError.我正在使用Canopy 1.4,所以熊猫0.13.1应该足够新,才能具有此功能.
I get EOFError. I am using Canopy 1.4 so pandas 0.13.1 which should be recent enough to have this functionality.
推荐答案
快进几年了,现在工作正常.谢谢熊猫;)
Fast forward a few years, and now it works fine. Thanks pandas ;)
这篇关于腌制一个DataFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!