我有数据框 x,
我们想使用以下函数创建新列,它将在开始时添加完整列值并创建新列完成。
import datetime
def date_by_adding_business_days(from_date, add_days):
business_days_to_add = add_days
current_date = from_date
while business_days_to_add > 0:
current_date += datetime.timedelta(days=1)
weekday = current_date.weekday()
if weekday >= 5: # sunday = 6
continue
business_days_to_add -= 1
return current_date
我试过这个低于错误,请帮助。
x['Finish'] = x.apply(date_by_adding_business_days(datetime.date.today(), x['Complete']))
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().