1

My goal is to read the time data from the excel file and perform math on the time data in Python; in the same exact time format - hours:minutes:seconds.

I want to calculate average talk time, average wait time, and the sum of the total time for each column in the hours:minutes:seconds format in Python

*Data in excel file
 Name  Wait Time  Talk Time
 TA    00:00:45   00:00:30
 RN    00:00:44   00:04:31
 BK    00:00:45   00:02:35
 BK    00:02:16   00:02:27
 VD    00:00:07   00:08:07
 BC    00:00:07   00:00:01

import pandas as pd
dataset = pd.read_excel("time.xlsx",sheet_name='Q1')
dataset.dtypes
Name object
Wait Time object
Talk Time object

Is there a way to perform math operations (average and sum) in Python on time formatted (hours:minutes:seconds) DATA read from an excel file?

TAbdiukov
  • 1,185
  • 3
  • 12
  • 25
S Rob
  • 11
  • 2

1 Answers1

0

First you need to convert your time columns to datetime or timedelta.

Next you can simply use mean, min, max aso. which is already answered here f.e.:

Mean of time component only of pandas datetime column

Pandas - convert strings to time without date

x4k3p
  • 1,598
  • 2
  • 22
  • 42