Skip to content

Instantly share code, notes, and snippets.

@michaelaye
Created January 16, 2014 05:54
Show Gist options
  • Save michaelaye/8450433 to your computer and use it in GitHub Desktop.
Save michaelaye/8450433 to your computer and use it in GitHub Desktop.
Find non-nominal time deltas
# df is a pandas DataFrame
ts = pd.TimeSeries(df.index)
tdiff = ts.diff()
print tdiff.value_counts()
128000000 27976
129000000 91
127000000 57
1152000000 1
-2938000000 1
2176000000 1
-9223372036854775808 1
dtype: int64
ok_times = [pd.to_timedelta(str(i)+'ms') for i in [127,128,129]]
tdiff[~tdiff.isin(ok_times)]
0 NaT
6538 00:00:02.176000
6546 -00:00:02.938000
6562 00:00:01.152000
dtype: timedelta64[ns]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment