Black Lives Matter. Please consider donating to Black Girls Code today.

Grant charts without dates

I am trying to create Gantt chart which will represent timeline in seconds from 0 time. Therefore my data will look like this:

df = [dict(Task=“Foo”, Start=‘1.02’, Finish=‘1.03’),
dict(Task=“Bar”, Start=‘1.05’, Finish=‘1.07’),
dict(Task=“FooBar”, Start=‘1.25’, Finish=‘1.32’)]

fig = ff.create_gantt(df)

Can this be done without me transforming my time marks such as 1.02 to a fake date?

Also the actual array of dict will have different keys. Is there way to configure grantt chart to use my keys, so I don’t have to transform my keys to name grantt understands?



I found this solution on stackoverflow which would solve the key-issue by making an extra list:

data = []

for row in df.itertuples():
    data.append(dict(Task=str(row.X), Start=str(row.Y), Finish=str(row.Z), Resource=str(row.Z2)))

The link is generally useful for some styling of the Gantt-Chart

If the list is to slow and you want to keep the original, copying the Dataframe with new keys can be also a solution:

df_edit = df.rename(columns={"X": "Start", "Y": "Finish"})

Concerning the time, could a conversion of the column to timedelta help? (not an expert here either)