简体   繁体   English

sklearn SimpelImputer 系统错误:<built-in function _abc_instancecheck> 返回带有错误集的结果

[英]sklearn SimpelImputer SystemError: <built-in function _abc_instancecheck> returned a result with an error set

I'm imputing missing values in a pipeline.我在管道中输入缺失值。

在此处输入图片说明

In a first step I bin the variable in using:在第一步中,我将使用的变量装箱:

df_listings['original.listing.rooms.bedrooms.count'] = pd.cut(df_listings['original.listing.rooms.bedrooms.count'], bins = [1,2,3,4,5,6,10,50])
df_listings = df_listings.fillna(np.nan)

在此处输入图片说明

In a second step I want to impute the column using在第二步中,我想使用

si = SimpleImputer(missing_values=np.nan,strategy="most_frequent")
si.fit_transform(df_listings[['original.listing.rooms.bedrooms.count']])

Even though I followed this flow with other variables, here I get the following error:尽管我使用其他变量遵循此流程,但在这里我收到以下错误:

TypeError: unsupported operand type(s) for +: 'pandas._libs.interval.Interval' and 'pandas._libs.interval.Interval'

The above exception was the direct cause of the following exception:


...

SystemError: <built-in function _abc_instancecheck> returned a result with an error set

I can't understand the reason why I get this error.我无法理解我收到此错误的原因。 For other variables, I can work with pandas.Interval, just this variable causes an issue.对于其他变量,我可以使用 pandas.Interval,只是这个变量会导致问题。

当我们处理分类数据时,将 .astype(str) 添加到您的 pd.cut 可以解决问题。

df_listings['original.listing.rooms.bedrooms.count'] = pd.cut(df_listings['original.listing.rooms.bedrooms.count'], bins = [1,2,3,4,5,6,10,50]).astype(str)

暂无
暂无

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

相关问题 系统错误:<built-in function xxx_iterator> 返回带有错误集的结果 - SystemError: <built-in function xxx_iterator> returned a result with an error set Django:系统错误:<built-in function uwsgi_sendfile> 返回带有错误集的结果</built-in> - Django: SystemError: <built-in function uwsgi_sendfile> returned a result with an error set 系统错误:<built-in function puttext> 返回 NULL 没有设置错误</built-in> - SystemError: <built-in function putText> returned NULL without setting an error 为什么我会得到`SystemError:<built-in method __contains__ of dict object at ...> 导入“pydrake”东西时返回带有错误集的结果?</built-in> - Why do I get `SystemError: <built-in method __contains__ of dict object at ...> returned a result with an error set` when importing `pydrake` stuff? Tensorflow - 导入错误:系统错误:<built-in method __contains__ of dict object at 0x00000244b47addb8> 返回带有错误集的结果</built-in> - Tensorflow - ImportError: SystemError: <built-in method __contains__ of dict object at 0x00000244B47ADDB8> returned a result with an error set cv2.imwrite() 系统错误:<built-in function imwrite> 返回 NULL 没有设置错误</built-in> - cv2.imwrite() SystemError: <built-in function imwrite> returned NULL without setting an error 系统错误:<built-in function imread> 返回 NULL 没有设置错误(tkinter)</built-in> - SystemError: <built-in function imread> returned NULL without setting an error (tkinter) 如何修复“系统错误:<built-in function 'name'> 在 Python C 扩展中返回 NULL 而不设置错误” - How to fix "SystemError: <built-in function 'name'> returned NULL without setting an error" in Python C Extension python opencv '系统错误:<built-in function drawkeypoints> 在没有设置错误的情况下返回 NULL'</built-in> - python opencv 'SystemError: <built-in function drawKeypoints> returned NULL without setting an error' cv2.imread 错误:img = cv2.imread(0) 系统错误:<built-in function imread> 返回 NULL 没有设置错误</built-in> - cv2.imread error:img = cv2.imread(0) SystemError: <built-in function imread> returned NULL without setting an error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM