How to get the mean time between dates in JSON format string in Python

1 Answer

0 votes
import pandas as pd
 
JSON = [{'part':1, 'time':"2022-08-15 8:17:12"},
        {'part':1, 'time':"2022-08-15 8:18:20"},     
        {'part':2, 'time':"2022-08-15 8:21:14"},
        {'part':3, 'time':"2022-08-15 9:02:03"}]
 
mn = pd.to_datetime(pd.DataFrame(JSON)['time']).diff().mean()
 
print(mn)


 
'''
run:
 
0 days 00:14:57

'''

 



answered Sep 23, 2022 by avibootz
...