Created
January 16, 2014 05:54
-
-
Save michaelaye/8450433 to your computer and use it in GitHub Desktop.
Find non-nominal time deltas
This file contains 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
# 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