python - AWS Sagemaker Studio,无法加载pickle文件

标签 python amazon-web-services pickle amazon-sagemaker

我是 Sagemaker 的新手,我正在尝试将 pickle 数据集加载到 sagemaker 笔记本中。 我正在使用 Python 3(数据科学)内核和 ml.t3.medium 实例。 我要么从 S3 加载 pickle,要么直接从工作室上传,如下所示:

import pickle5
with open('filename', 'rb') as f:
    x = pickle.load(f)

我收到此错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/opt/conda/lib/python3.7/site-packages/IPython/core/formatters.py in __call__(self, obj)
    700                 type_pprinters=self.type_printers,
    701                 deferred_pprinters=self.deferred_printers)
--> 702             printer.pretty(obj)
    703             printer.flush()
    704             return stream.getvalue()

..................... more errors here


/opt/conda/lib/python3.7/site-packages/pandas/core/generic.py in __getattr__(self, name)
   5268             or name in self._accessors
   5269         ):
-> 5270             return object.__getattribute__(self, name)
   5271         else:
   5272             if self._info_axis._can_hold_identifiers_and_holds_name(name):

pandas/_libs/properties.pyx in pandas._libs.properties.AxisProperty.__get__()

/opt/conda/lib/python3.7/site-packages/pandas/core/generic.py in __getattr__(self, name)
   5268             or name in self._accessors
   5269         ):
-> 5270             return object.__getattribute__(self, name)
   5271         else:
   5272             if self._info_axis._can_hold_identifiers_and_holds_name(name):

AttributeError: 'DataFrame' object has no attribute '_data'

最佳答案

你能检查一下你的 Pandas 版本吗?当 pickled 文件是用旧的 Pandas 版本编写时,通常会发生此错误。您的 Sagemaker 笔记本可能运行 Pandas > 1.1,而 pickle 数据帧的 Pandas 可能是 < 1.1

关于python - AWS Sagemaker Studio,无法加载pickle文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67361483/

相关文章:

amazon-web-services - AWS S3 网站版本控制

python - 如何 pickle 自己?

python - Pickle: AttributeError: 'module' 对象没有属性

python - 使用自定义属性保存/加载 Pandas 数据框

python - 这里可能有更好的算法吗?

Python:从交通摄像头获取 10 分钟视频

python - 发电机 : Update atomic counter and add other info if new item

amazon-web-services - 在 Amazon AWS Lightsail SSH 终端 vim 中转义 'insert' 模式

Python Threading.Timer正在调用命令而无需等待

python - 使用pip安装时编译出错