Created
April 28, 2020 09:10
-
-
Save wizact/1662bfe735c8719ff5b089b42fda3b08 to your computer and use it in GitHub Desktop.
Calculate diff two dates in hours
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
df = pd.read_csv("./dates.csv") | |
df_length = len(df.index) | |
print("# Incidents: ", df_length) | |
df['A'] = pd.to_datetime(df["start_date"]) | |
df['B'] = pd.to_datetime(df["end_date"]) | |
df['MTTR'] = (df['B'] - df['A']).astype('timedelta64[h]') | |
print("MTTR: ", df['MTTR'].mean()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment