超出最大递归深度google colab

问题描述

尝试在Google colab上运行一些python代码。我需要读取一些预处理后的数据:

train,test,unused_feat,target_features,features,cat_idxs,cat_dims  = pickle.load(open('/content/drive/My Drive/xxx/data/train_test.pkl','rb'))

然后如果我打电话给我,我会收到错误消息:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/IPython/core/formatters.py in __call__(self,obj)
    697                 type_pprinters=self.type_printers,698                 deferred_pprinters=self.deferred_printers)
--> 699             printer.pretty(obj)
    700             printer.flush()
    701             return stream.getvalue()

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

/usr/local/lib/python3.6/dist-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'

当我打电话

---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
<ipython-input-35-5e6a15ce28a5> in <module>()
----> 1 train.shape

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

/usr/local/lib/python3.6/dist-packages/pandas/core/generic.py in __getattr__(self,name)
   5271         else:
   5272             if self._info_axis._can_hold_identifiers_and_holds_name(name):

RecursionError: maximum recursion depth exceeded while calling a Python object

当我在自己的Jupyter笔记本上工作时,我对此没有任何问题。我想知道出了什么问题。火车也包含大约25万行。

解决方法

我认为,如果这是您的约束条件,则可以更改递归限制,但是,您可能处于无休止的循环中。

这篇文章告诉您如何增加递归限制。 What is the maximum recursion depth in Python,and how to increase it?

但是,我不确定您遇到的另一个错误。希望能有所帮助。