O2O-Coupon-Usage-Forecast icon indicating copy to clipboard operation
O2O-Coupon-Usage-Forecast copied to clipboard

/wepon/season one 中extract_feature.py问题

Open fannn1217 opened this issue 6 years ago • 11 comments

请问在运行extract_feature.py时出现了这样的问题 Traceback (most recent call last): File "extract_feature.py", line 60, in feature3 = off_train[((off_train.date>='20160315')&(off_train.date<='20160630'))|((off_train.date=='null')&(off_train.date_received>='20160315')&(off_train.date_received<='20160630'))] File "/Library/Python/2.7/site-packages/pandas/core/ops.py", line 879, in wrapper res = na_op(values, other) File "/Library/Python/2.7/site-packages/pandas/core/ops.py", line 818, in na_op raise TypeError("invalid type comparison") TypeError: invalid type comparison 怎么解决呢

fannn1217 avatar Mar 08 '18 02:03 fannn1217

不好意思这个是环境变量问题你File "/Library/Python/2.7/site-packages/pandas/core/ops.py", line 818, in na_op raise TypeError("invalid type comparison") 修改成\看看 在2018年3月8日 10:49,fannn1217[email protected]mailto:[email protected] 写道:

请问在运行extract_feature.py时出现了这样的问题 Traceback (most recent call last): File "extract_feature.py", line 60, in feature3 = off_train[((off_train.date>='20160315')&(off_train.date<='20160630'))|((off_train.date=='null')&(off_train.date_received>='20160315')&(off_train.date_received<='20160630'))] File "/Library/Python/2.7/site-packages/pandas/core/ops.py", line 879, in wrapper res = na_op(values, other) File "/Library/Python/2.7/site-packages/pandas/core/ops.py", line 818, in na_op raise TypeError("invalid type comparison") TypeError: invalid type comparison 怎么解决呢

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/wepe/O2O-Coupon-Usage-Forecast/issues/12, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMAaSHvNq5g_zki3cCH5mBrqd54wLFt5ks5tcJwUgaJpZM4SiDaZ.

yunxinan avatar Mar 08 '18 09:03 yunxinan

你好请问下,这个怎么解决的?

解决了,在读取train文件时设置keep_default_na = False..我的是py3.可能就是nan的问题!

JackeYou avatar May 24 '18 00:05 JackeYou

@WorldBestGaming 您好,请问你的nan问题是如何解决,我遇到了这个问题“ValueError: invalid literal for int() with base 10: 'nan'”。

iimmortall avatar Jul 07 '18 04:07 iimmortall

@iimmortall 你pandas读取文件时,有个参数是keep_default_na你设置一下False就ok了。

JackeYou avatar Jul 08 '18 08:07 JackeYou

Cause there so many pd.read_csv..so when trackback the code ,which operaion should I change 'keep_defau.lt_na=False‘.I've changed some but the result is negative..

RobertMarton avatar Jul 17 '18 09:07 RobertMarton

@RobertMarton i can`t understand you say that the result is negative.= =! emmm

JackeYou avatar Jul 17 '18 15:07 JackeYou

Emmm, I added 'keep_default_na=False' in code "off_train = pd.read_csv('data/ccf_offline_stage1_train.csv',header=None,keep_default_na=False)"& "on_train = pd.read_csv('data/ccf_online_stage1_train.csv',header=None,keep_default_na=False)" But the error still exist like below =-= : t3['user_merchant_any'] = 1 (112803, 52) (257126, 53) Traceback (most recent call last): File "extract_feature.py", line 1031, in dataset2.label = dataset2.label.apply(get_label) File "/usr/local/lib/python2.7/dist-packages/pandas/core/series.py", line 3194, in apply mapped = lib.map_infer(values, f, convert=convert_dtype) File "pandas/_libs/src/inference.pyx", line 1472, in pandas._libs.lib.map_infer File "extract_feature.py", line 981, in get_label elif (date(int(s[0][0:4]),int(s[0][4:6]),int(s[0][6:8]))-date(int(s[1][0:4]),int(s[1][4:6]),int(s[1][6:8]))).days<=15: ValueError: invalid literal for int() with base 10: 'nan'

RobertMarton avatar Jul 19 '18 07:07 RobertMarton

I changed some code then ,when running xgb.py occurs error below: "Check failed: !auc_error AUC: the dataset only contains pos or neg samples" But the label column in dataset1.csv is all value 0 ,so is this normal?

RobertMarton avatar Jul 19 '18 12:07 RobertMarton

@RobertMarton How duo you solve this
elif (date(int(s[0][0:4]),int(s[0][4:6]),int(s[0][6:8]))-date(int(s[1][0:4]),int(s[1][4:6]),int(s[1][6:8]))).days<=15: ValueError: invalid literal for int() with base 10: 'nan' i also see this in my code. help me plz.

gutsttt avatar Jul 19 '18 15:07 gutsttt

@RobertMarton emmmm. My solution is based on python3.your enviorment is py2.I guess the data format is a problem, you can try to change utf-8. = =!

JackeYou avatar Jul 22 '18 15:07 JackeYou

nan的问题在比较前先把那列fillna('null')

ChenKevin0123 avatar Jan 23 '19 11:01 ChenKevin0123