Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行wepon/sesson one/extract_feature.py错误 #2

Closed
BoyuanJiang opened this issue Jan 13, 2017 · 8 comments
Closed

运行wepon/sesson one/extract_feature.py错误 #2

BoyuanJiang opened this issue Jan 13, 2017 · 8 comments

Comments

@BoyuanJiang
Copy link

Traceback (most recent call last):
File "extract_feature.py", line 99, in
t3['this_month_user_receive_same_coupon_lastone'] = t3.max_date_received - t3.date_received
File "/usr/lib64/python2.7/site-packages/pandas/core/ops.py", line 715, in wrapper
result = wrap_results(safe_na_op(lvalues, rvalues))
File "/usr/lib64/python2.7/site-packages/pandas/core/ops.py", line 676, in safe_na_op
return na_op(lvalues, rvalues)
File "/usr/lib64/python2.7/site-packages/pandas/core/ops.py", line 658, in na_op
result[mask] = op(x[mask], _values_from_object(y[mask]))
TypeError: unsupported operand type(s) for -: 'float' and 'str'

@wepe
Copy link
Owner

wepe commented Jan 14, 2017

你把line99换成这个试试

t3['this_month_user_receive_same_coupon_lastone'] = t3.max_date_received.astype('int') - t3.date_received.astype('int')

@BoyuanJiang
Copy link
Author

@wepe
改了后得到了以下的错误
Traceback (most recent call last):
File "extract_feature.py", line 99, in
t3['this_month_user_receive_same_coupon_lastone'] = t3.max_date_received.astype('int') - t3.date_received.astype('int')
File "/usr/lib64/python2.7/site-packages/pandas/core/generic.py", line 3054, in astype
raise_on_error=raise_on_error, **kwargs)
File "/usr/lib64/python2.7/site-packages/pandas/core/internals.py", line 3189, in astype
return self.apply('astype', dtype=dtype, **kwargs)
File "/usr/lib64/python2.7/site-packages/pandas/core/internals.py", line 3056, in apply
applied = getattr(b, f)(**kwargs)
File "/usr/lib64/python2.7/site-packages/pandas/core/internals.py", line 461, in astype
values=values, **kwargs)
File "/usr/lib64/python2.7/site-packages/pandas/core/internals.py", line 504, in _astype
values = _astype_nansafe(values.ravel(), dtype, copy=True)
File "/usr/lib64/python2.7/site-packages/pandas/types/cast.py", line 531, in _astype_nansafe
raise ValueError('Cannot convert NA to integer')
ValueError: Cannot convert NA to integer

@wepe
Copy link
Owner

wepe commented Jan 14, 2017

ValueError: Cannot convert NA to integer

你应该是date_received这一列数据有问题,我的可以跑通,你确定一下自己下载的数据没问题? date_received字段的数据是 20160701 这种格式的。

@BoyuanJiang
Copy link
Author

确定数据没有问题,
image
这个是执行line 99之前的t3的内容,我想会不会是我的pandas版本的问题,请问你的pandas的版本是多少?

@wepe
Copy link
Owner

wepe commented Jan 14, 2017

我的pandas 版本:0.18.1

@BoyuanJiang
Copy link
Author

确实是我的原始数据有些问题,谢谢

@CXY573
Copy link

CXY573 commented Jan 18, 2018

@BoyuanJiang 你用的数据不是作者提供的数据吗,我也出现你这个错误了 请问怎么解决的

@aojue1109
Copy link

@BoyuanJiang 请问数据有什么问题,我也在这个点上出现了问题,不确定数据在哪里有问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants