[英]SystemError: <built-in function xxx_iterator> returned a result with an error set
[英]sklearn SimpelImputer SystemError: <built-in function _abc_instancecheck> returned a result with an error set
我在管道中輸入缺失值。
在第一步中,我將使用的變量裝箱:
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)
在第二步中,我想使用
si = SimpleImputer(missing_values=np.nan,strategy="most_frequent")
si.fit_transform(df_listings[['original.listing.rooms.bedrooms.count']])
盡管我使用其他變量遵循此流程,但在這里我收到以下錯誤:
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
我無法理解我收到此錯誤的原因。 對於其他變量,我可以使用 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.