jeudi 30 janvier 2020

Problem in taking difference in timestamp

I have a timestamp column for 30 seconds resolution for 10 days. I want to take a difference between them, but difference between them should be zero when date changes. I have written below code but it is not giving me the solution i require

for i in range(len(df1)-1):
    if (df1.iloc[i+1, 22] == df1.iloc[i, 22]):
        df1.ix[i+1, ['Time']] = df1.iloc[i+1, 24] - df1.iloc[i, 24]
    else:
        df1.ix[i+1, ['Time']] = np.nan

I have seperated date and time into sepereate columns df1.iloc[i+1, 22] is the date column, df1.iloc[i+1, 24] is the time column

How can i Proceed?

Aucun commentaire:

Enregistrer un commentaire