File: moments_rolling_binary.py

package info (click to toggle)
pandas 0.14.1-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 54,924 kB
  • ctags: 53,113
  • sloc: python: 130,524; ansic: 11,510; sh: 329; makefile: 118
file content (30 lines) | stat: -rw-r--r-- 617 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from moment_plots import *

np.random.seed(1)

ts = test_series()
s = ts.cumsum()
ts2 = test_series()
s2 = ts2.cumsum()

s[20:50] = np.NaN
s[120:150] = np.NaN
fig, axes = plt.subplots(3, 1, figsize=(8, 10), sharex=True)

ax0, ax1, ax2 = axes

ax0.plot(s.index, s.values)
ax0.plot(s2.index, s2.values)
ax0.set_title('time series')

ax1.plot(s.index, m.rolling_corr(s, s2, 50, min_periods=1).values)
ax1.set_title('rolling_corr')

ax2.plot(s.index, m.rolling_cov(s, s2, 50, min_periods=1).values)
ax2.set_title('rolling_cov')

fig.autofmt_xdate()
fig.subplots_adjust(bottom=0.10, top=0.95)

plt.show()
plt.close('all')