ShichenXie / scorecardpy

Scorecard Development in python, 评分卡
http://shichen.name/scorecard
MIT License
725 stars 301 forks source link

ValueError: fill value must be in categories pandas Version: 0.24.2 #18

Closed happyjay23 closed 5 years ago

happyjay23 commented 5 years ago

RemoteTraceback Traceback (most recent call last) RemoteTraceback: """ Traceback (most recent call last): File "D:\Anaconda3\lib\multiprocessing\pool.py", line 121, in worker result = (True, func(args, kwds)) File "D:\Anaconda3\lib\multiprocessing\pool.py", line 47, in starmapstar return list(itertools.starmap(args[0], args[1])) File "D:\Anaconda3\lib\site-packages\scorecardpy\woebin.py", line 950, in woepoints_ply1 dtx = dtx.fillna('missing').assign(rowid = dtx.index) File "D:\Anaconda3\lib\site-packages\pandas\core\frame.py", line 4034, in fillna downcast=downcast, kwargs) File "D:\Anaconda3\lib\site-packages\pandas\core\generic.py", line 6123, in fillna downcast=downcast) File "D:\Anaconda3\lib\site-packages\pandas\core\internals\managers.py", line 525, in fillna return self.apply('fillna', kwargs) File "D:\Anaconda3\lib\site-packages\pandas\core\internals\managers.py", line 395, in apply applied = getattr(b, f)(kwargs) File "D:\Anaconda3\lib\site-packages\pandas\core\internals\blocks.py", line 1834, in fillna values = values.fillna(value=value, limit=limit) File "D:\Anaconda3\lib\site-packages\pandas\util_decorators.py", line 188, in wrapper return func(args, **kwargs) File "D:\Anaconda3\lib\site-packages\pandas\core\arrays\categorical.py", line 1784, in fillna raise ValueError("fill value must be in categories") ValueError: fill value must be in categories """

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

ValueError Traceback (most recent call last)

in 1 # converting train and test into woe values ----> 2 train_woe = sc.woebin_ply(train, bins_adj) 3 test_woe = sc.woebin_ply(test, bins_adj) 4 5 y_train = train_woe.loc[:,'creditability'] D:\Anaconda3\lib\site-packages\scorecardpy\woebin.py in woebin_ply(dt, bins, no_cores, print_step) 1059 ) 1060 # bins in dictionary -> 1061 dat_suffix = pool.starmap(woepoints_ply1, args) 1062 dat = pd.concat([dat]+dat_suffix, axis=1) 1063 pool.close() D:\Anaconda3\lib\multiprocessing\pool.py in starmap(self, func, iterable, chunksize) 274 `func` and (a, b) becomes func(a, b). 275 ''' --> 276 return self._map_async(func, iterable, starmapstar, chunksize).get() 277 278 def starmap_async(self, func, iterable, chunksize=None, callback=None, D:\Anaconda3\lib\multiprocessing\pool.py in get(self, timeout) 655 return self._value 656 else: --> 657 raise self._value 658 659 def _set(self, i, obj): ValueError: fill value must be in categories 我在python3.7下运行不动
sunrisehang commented 5 years ago

能发现你把运行的代码给我看看嘛?

happyjay23 commented 5 years ago
你好,我就是运行的官方演示代码,在Python3.7下运行的, 

converting train and test into woe values

train_woe = sc.woebin_ply(train, bins_adj)

test_woe = sc.woebin_ply(test, bins_adj)

就是这段,sc.woebin_ply

------------------------原始邮件------------------------

发信人:xiaohangnotifications@github.com

时间:12:56:56 下午

收信人:ShichenXie/scorecardpyscorecardpy@noreply.github.com

抄送:happyjay23happyjay23@sina.com ,Authorauthor@noreply.github.com

标题:Re: [ShichenXie/scorecardpy] ValueError: fill value must be in categories pandas Version: 0.24.2 (#18)

能发现你把运行的代码给我看看嘛? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

ShichenXie commented 5 years ago

不知道你的python环境是怎么配置的。建议使用anaconda

happyjay23 commented 5 years ago
使用的最新anaconda和py37下试的 

------------------------原始邮件------------------------

发信人:Shichennotifications@github.com

时间:07:33:18 下午

收信人:ShichenXie/scorecardpyscorecardpy@noreply.github.com

抄送:happyjay23happyjay23@sina.com ,Authorauthor@noreply.github.com

标题:Re: [ShichenXie/scorecardpy] ValueError: fill value must be in categories pandas Version: 0.24.2 (#18)

不知道你的python环境是怎么配置的。建议使用anaconda — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

77QingLiu commented 5 years ago

issue + 1

Yico123 commented 5 years ago

issue + 1

sunrisehang commented 5 years ago

导致报错的原因就是,pandas最新版本0.24.2和目前的scorecardpy版本不兼容,我尽快改正scorecardpy。 然后,救火的办法是,把pandas版本降级: 1.找到anacoda prompt软件,以管理员身份运行,卸载最新的pandas,命令是:conda uninstall pandas 2.安装老一点的pandas,命令时:conda install pandas==0.23.2 PS:我亲自把pandas升级了一下,报错;然后按照这个办法降级,就不再报错了,可以正常使用了。

sunrisehang commented 5 years ago

21

我找到解决方法了,在新的pull requests里