import io
import pandas as pd
data = """\
task,start,end
A,6:00,8:30
B,6:30,8:00
C,5:30,7:00
D,7:30,9:00
E,10:00,10:30
F,5:00,11:00
"""
df0 = pd.read_csv(io.StringIO(data), index_col=0)
df0["start"] = pd.to_timedelta(df0["start"] + ":00")
df0["end"] = pd.to_timedelta(df0["end"] + ":00")
df0
sr0 = pd.Series(df0.stack().unique()).sort_values().reset_index(drop=True)
sr0
df1 = pd.DataFrame({"start": sr0, "end": sr0.shift(-1)}).dropna()
df2 = df0.reset_index().merge(df1.reset_index(), how="cross")
df2["task"] = df2["task"].where(
(df2["start_x"] <= df2["start_y"]) & (df2["end_x"] >= df2["end_y"])
)
df2.dropna(subset="task", inplace=True)
df3 = df2.pivot(index="index", columns="task", values="task")
df1["work"] = df3.apply(lambda x: pd.Series(x.dropna().values), axis=1).iloc[:, 0]
df1
df1["time"] = df1["end"] - df1["start"]
result = df1.groupby(by="work")["time"].sum().reindex(df0.index, fill_value=pd.Timedelta(0))
result