问题描述
我已经修复了导致DataError的错误,但是我不知道如何明确地捕获它:
try:
df [我的列] = df.baddata + df.morebaddata
除了DataError:
打印抓到错误!
提供: NameError:name'DataError'未定义
然后我尝试了 pd.core.frame.DataError
并收到一个 AttributeError的
。我也试过Googling这个,但找不到一个熊猫错误类型的列表。 DataError
的正确路径是什么?
我有相同的问题,你可以解决如下:
from django.db import DataError
/ pre>
添加例外
除了DataError:
我设法解决这个问题,下面是文档的链接。
I have since fixed the bug that caused the DataError, but I can not for the life of me figure out how to catch it explicitly:
try: df["my column"] = df.baddata + df.morebaddata except DataError: print "Caught Error!"
Gives:
NameError: name 'DataError' is not defined
Then I tried
pd.core.frame.DataError
and received anAttributeError
. I also tried Googling this but could not find a list of pandas error types. What is the correct path forDataError
?解决方案I had the same problem, you can solve as follows:
from django.db import DataError
Add the exception
except DataError:
I managed to solve this way, below is the link of the documentation.
这篇关于如何捕捉一个大 pandas DataError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!