Im trying to create a column that gives the variance or subtraction of two timestamps of two other columns.
def time_delta(df):
if df['a_time'] > df['b_time']:
df = (pd.to_datetime(df.a_time) - pd.to_datetime(df.b_time)) / np.timedelta64(1, 'm')
else:
df = (pd.to_datetime(df.b_time) - pd.to_datetime(df.a_time)) / np.timedelta64(1, 'm')
return df
df['C'] = df.apply(time_delta, axis=1)
When I run the apply part of code the cell just keeps running with *, am I missing something?
Thanks so much
Aucun commentaire:
Enregistrer un commentaire