簡體   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