AWS Sagemaker Studio,无法加载 pickle 文件

AWS Sagemaker Studio, cannot load pickle files

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

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 notebook 可能运行 Pandas > 1.1,其中 pickle 数据框的 Pandas 可能 < 1.1