I need to create a report where I need to subtract two dates and return it in the form of %H:%M%S
This is the subtraction which I inserted into a list :
you can use a custom function that converts timedelta to H:M:S string:
def td_to_str(td):
"""
convert a timedelta object td to a string in HH:MM:SS format.
"""
hours, remainder = divmod(td.total_seconds(), 3600)
minutes, seconds = divmod(remainder, 60)
return f'{int(hours):02}:{int(minutes):02}:{int(seconds):02}'
s = pd.Series(pd.to_timedelta(['1 day, 00:05:39']))
s.apply(td_to_str)
# 0 24:05:39
# dtype: object