pandas利用bdate_range计算两个时间列的工作日差值
有两列时间
in1:df_yunying_merge['提交财务时间(线下)'].head()
out1:
0 2021-09-29
1 2021-09-29
2 2021-09-29
3 2021-09-29
4 2021-09-29
in2:df_yunying_merge['支付时间'].head()
out2:
0 2021-10-12
1 2021-10-12
2 2021-10-12
3 2021-10-12
4 2021-10-12
# 计算过程:
in3:
def cal_businessday(df):
businessday = pd.bdate_range(start=df['提交财务时间(线下)'],end=df['支付时间'])
businessday_count = businessday.shape[0]
return businessday_count
df_yunying_merge['财务处理周期(天)'] = df_yunying_merge.apply(cal_businessday,axis=1)