问题描述
Customer_Id Call_Date Agent_M_Code Row_Indicator
810471698 2020-03-19 13:25:24.910 rmanzan2 1
810471698 2020-03-22 20:28:19.067 pmaclair 2
810471698 2020-03-24 09:22:47.833 njeanle 3
810471698 2020-03-24 12:36:29.367 edelaro4 4
810471698 2020-03-29 22:36:29.762 kdularo7 1
810471698 2020-04-11 11:21:11.243 rbustam1 1
810471698 2020-04-11 17:50:41.023 frenteri 2
810471698 2020-05-10 11:16:21.683 cschuch2 1
810471698 2020-05-13 15:26:40.660 gledesma 2
810471698 2020-07-03 11:26:20.697 cmataver 1
810471698 2020-07-22 14:19:53.450 irodri13 1
对于上表,我需要生成row_indicators,但是这里的条件是...如果上方的Call_Date和下方的call_Date在10天之间,那么我们需要按顺序生成row_indicator,即(1,2,3, 4 ..)如果不是,我们需要从1开始。
示例:在上述示例表中,前四行在10天之间(小于或等于240小时),然后对于前四行,row_indicators为1,3 ,4,然后从第五行开始,Call_Date从1开始,因为第五行日期不在10天Call_Date范围内。
解决方法
您需要对此进行递归查询。这个想法是通过递增import plotly.graph_objects as go
from plotly.subplots import make_subplots
# Create figure with secondary y-axis
fig = make_subplots(specs=[[{"secondary_y": True}]])
# Add traces
fig.add_trace(
go.Scatter(x=[1,2,3],y=[40,50,60],name="yaxis data"),secondary_y=False,)
fig.add_trace(
go.Scatter(x=[2,3,4],y=[80,40,30],name="yaxis2 data"),secondary_y=True,)
# Add figure title
fig.update_layout(
title_text="Double Y Axis Example"
)
# Set x-axis title
fig.update_xaxes(title_text="xaxis title")
# Set y-axes titles
fig.update_yaxes(title_text="<b>primary</b> yaxis title",secondary_y=False)
fig.update_yaxes(title_text="<b>secondary</b> yaxis title",secondary_y=True)
fig.show()
迭代遍历表格,同时跟踪每个日期的“第一”记录。每当行距初始日期晚10天以上时,该值就会重置。
call_date