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

在运行get_day_gap_before时出现了问题 #23

Open
tangxxx121 opened this issue Aug 12, 2022 · 1 comment
Open

在运行get_day_gap_before时出现了问题 #23

tangxxx121 opened this issue Aug 12, 2022 · 1 comment

Comments

@tangxxx121
Copy link

t7['day_gap_before'] = t7.date_received_date.apply(get_day_gap_before)
Traceback (most recent call last):

File "C:\Users\TangX\AppData\Local\Temp\ipykernel_10460\2415590082.py", line 1, in <cell line: 1>
t7['day_gap_before'] = t7.date_received_date.apply(get_day_gap_before)

File "F:\Anaconda_app\lib\site-packages\pandas\core\series.py", line 4433, in apply
return SeriesApply(self, func, convert_dtype, args, kwargs).apply()

File "F:\Anaconda_app\lib\site-packages\pandas\core\apply.py", line 1082, in apply
return self.apply_standard()

File "F:\Anaconda_app\lib\site-packages\pandas\core\apply.py", line 1137, in apply_standard
mapped = lib.map_infer(

File "pandas_libs\lib.pyx", line 2870, in pandas._libs.lib.map_infer

File "C:\Users\TangX\AppData\Local\Temp\ipykernel_10460\2229747806.py", line 6, in get_day_gap_before
this_gap = (date(int(date_received[0:4]),int(date_received[4:6]),int(date_received[6:8]))-date(int(d[0:4]),int(d[4:6]),int(d[6:8]))).days

ValueError: invalid literal for int() with base 10: 'Date'

@tangxxx121
Copy link
Author

找到问题了,在读取文件时有header=None,并且后面有重新设置了列名 off_train.columns= ['user_id','merchant_id','coupon_id','discount_rate','distance','date_received','date']。导致原来的列名现在变成了第0行的数据。这样的问题大家怎么解决的了?

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

1 participant