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

Creating Gantt_Chart from Database

Hi all,

I’m trying to create a Gantt Chart by using a data frame. I want to use it to show when a vehicle is going to be in maintenance. Unfortunately I don’t get it working. I already tried the following code:

FYI: the data frame df_vehicle_data is filled with all data of my database. The column vid is already existing in my database. That’s why it I haven’t created a column as I did for Start and Finish.

df_vehicle_data["Start"] = '2020-01-01'
df_vehicle_data["Finish"] = '2021-01-01'

df = df_vehicle_data[['vid', 'Start', 'Finish']]

for i in range (0,4):
    df_maintenance_calendar = [dict(Task=df.vid[i], Start=df['Start'][i], Finish=df['Finish'][i])]
    gantt_chart = ff.create_gantt(df_maintenance_calendar)

When I print the df_maintenance_calendar - that’s the result:

But in my app only one task (instead of 4) is created:

Could you please help me with that issue! I would really appreciate any help.

Thanks in advance!
Best regards

I haven’t looked too closely at your example, but just FYI that we released a brand new version of the gantt chart in 📣 Announcing 4.9 - Kaleido for static image export, Hexbin Tile Maps, and Timelines called px.timeline. Going forward, I’d recommend using that function instead of ff.create_gantt since we’re putting more effort into the px functions