繁体   English   中英

大熊猫腌渍错误 - 超出最大递归深度

[英]Pandas to pickle error - maximum recursion depth exceeded

我是Python及其pickle格式的新手。

所以当我写到to_pickle时,我遇到了一条错误消息。

>>> import pandas as pd
>>> old = pd.read_pickle('vol.pkl')
>>> old = old.append(updates)
>>> pd.to_pickle(old,'vol.pkl')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "\\\python-site-packages\win64_vc11\Lib\site-packages\pandas-0.13.0-py2.7-win-amd64.egg\pandas\io\pickle.py", line 15, in to_pickle
    pkl.dump(obj, f, protocol=pkl.HIGHEST_PROTOCOL)
  File "\\\python-site-packages\win64_vc11\Lib\site-packages\bs4\element.py", line 664, in __getnewargs__
    return (unicode(self),)
RuntimeError: maximum recursion depth exceeded while calling a Python object

谁知道为什么会这样,以及如何解决这个问题?

谢谢。

我有同样的问题。 在我的情况下,它是由向数据帧添加bs4.element.NavigableString元素引起的。 将其转换为字符串解决了问题!

注释“在行返回(unicode(self),):变量self的值是多少?” 把我解决了,谢谢! 我注意到错误消息中的bs4 \\ element.py。 我意识到我(意外地)也在我的数据框中添加了bs4项。 我错误地认为soup.title.string返回了一个字符串,但它返回了一个类型bs4.element.NavigableString。

    # the issue: type(title) = bs4.element.NavigableString

    ~\Anaconda3\lib\site-packages\bs4\element.py in __getnewargs__(self)
    784 
    785     def __getnewargs__(self):
--> 786         return (str(self),)
    787 
    788     def __getattr__(self, attr):

RecursionError: maximum recursion depth exceeded while getting the str of an object

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM