我需要一个具有以下结构的数据帧(dfGant):
Task Start Finish Resource
0 1 MS: undef. Stop 06:57:03 06:57:18 PL
1 2 BD: Sealent fail PRST 06:57:18 06:59:08 AV
2 3 MS: MDA or JOG 06:59:08 07:28:03 PL
3 4 MS: E-Stop Button 07:28:03 07:28:08 PL
4 5 MS: undef. Stop 07:28:08 07:31:08 PL
我需要在Python中使用断条或甘特图样式,在x轴上使用时间戳,在y轴上使用分类数据(任务)并为资源列着色。这个任务一天出现几次。我在网上找不到真正有用的东西。我不想手动设置dict我的数据帧有数千行和大约20个类别。最后我需要一个三色图表x轴时间戳。像这样的图片输出。你知道吗
def gantDict(data):
for a,b,c,d in zip(data.Task,data.Start,data.Finish,data.Resource):
dfRead = [dict(Task=a, Start=b, Finish=c, Resource=d)]
for item in dfRead:
dfList.append(item)
return dfList
gantDict(dfGant)
fig = ff.create_gantt(dfList)
您可以将数据帧传递给函数,而无需将其转换为字典列表:
相关问题 更多 >
编程相关推荐