how count average from exel using python
Question:
how count time average from excel using python row b or c
This my code
from datetime import datetime
import pandas as pd
import numpy as np
df = pd.read_excel('convert.xlsx')
t1 = pd.to_datetime(df['b'], format='%H:%M:%S')
t2 = pd.to_datetime(df['c'], format='%H:%M:%S')
delta = t2 - t1
print(delta)
Answers:
You can use the .mean() function on the ‘delta’ variable to calculate the average time difference between the values in columns ‘b’ and ‘c’.
For example:
print(delta.mean())
This will output the average time difference between the values in columns ‘b’ and ‘c’ in the format ‘0 days 00:00:00.000000’
Alternatively, you can use the .mean() function on the ‘delta’ variable after converting it to seconds using the .total_seconds() method
For example:
print(delta.mean().total_seconds())
This will output the average time difference between the values in columns ‘b’ and ‘c’ in seconds.
how count time average from excel using python row b or c
This my code
from datetime import datetime
import pandas as pd
import numpy as np
df = pd.read_excel('convert.xlsx')
t1 = pd.to_datetime(df['b'], format='%H:%M:%S')
t2 = pd.to_datetime(df['c'], format='%H:%M:%S')
delta = t2 - t1
print(delta)
You can use the .mean() function on the ‘delta’ variable to calculate the average time difference between the values in columns ‘b’ and ‘c’.
For example:
print(delta.mean())
This will output the average time difference between the values in columns ‘b’ and ‘c’ in the format ‘0 days 00:00:00.000000’
Alternatively, you can use the .mean() function on the ‘delta’ variable after converting it to seconds using the .total_seconds() method
For example:
print(delta.mean().total_seconds())
This will output the average time difference between the values in columns ‘b’ and ‘c’ in seconds.