Skip to content

Instantly share code, notes, and snippets.

@wizact
Created April 28, 2020 09:10
Show Gist options
  • Save wizact/1662bfe735c8719ff5b089b42fda3b08 to your computer and use it in GitHub Desktop.
Save wizact/1662bfe735c8719ff5b089b42fda3b08 to your computer and use it in GitHub Desktop.
Calculate diff two dates in hours
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