Skip to content

Commit 91356be

Browse files
committed
analysis: fake 1s precision of rolling event rate
There's a lot of magic going on between how the datetime64 values actually encode datetime in plots. Sharing an axis across (sub)plots is brittle w.r.t. these differences. Work around this, here: make it so that individual timestamps have a non-zero value for seconds, by simply adding one second, shifting the whole data set by one second to the left. That prevents, I guess, an optimization to hit in which would see that individual timestamps hit the full hour or integer multiples of 30 or 15 minutes. Also see pandas-dev/pandas#15874 pandas-dev/pandas#15071 pandas-dev/pandas#31074 pandas-dev/pandas#29705 pandas-dev/pandas#29719 pandas-dev/pandas#18571 pandas-dev/pandas#11574 pandas-dev/pandas#22586
1 parent 542a6d8 commit 91356be

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

cia/analysis.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,22 @@ def calc_rolling_event_rate(series, window_width_seconds, upsample=False):
112112
# rolling_event_rate_d = rolling_event_rate_d[window_width_seconds:]
113113
# print(rolling_event_rate_d)
114114

115+
# There's a lot of magic going on between how the datetime64 values
116+
# actually encode datetime in plots. Sharing an axis across (sub)plots is
117+
# brittle w.r.t. these differences. Work around this, here: make it so that
118+
# individual timestamps have a non-zero value for seconds, by simply adding
119+
# one second, shifting the whole data set by one second to the left. That
120+
# prevents, I guess, an optimization to hit in which would see that
121+
# individual timestamps hit the full hour or integer multiples of 30 or 15
122+
# minutes. Also see
123+
# https://github.com/pandas-dev/pandas/issues/15874
124+
# https://github.com/pandas-dev/pandas/issues/15071
125+
# https://github.com/pandas-dev/pandas/issues/31074
126+
# https://github.com/pandas-dev/pandas/issues/29705
127+
# https://github.com/pandas-dev/pandas/issues/29719
128+
# https://github.com/pandas-dev/pandas/issues/18571
129+
# https://github.com/pandas-dev/pandas/issues/11574
130+
# https://github.com/pandas-dev/pandas/issues/22586
131+
rolling_event_rate_d.index = rolling_event_rate_d.index + pd.to_timedelta("1 sec")
132+
115133
return rolling_event_rate_d

0 commit comments

Comments
 (0)