Skip to content

Commit 677c3cc

Browse files
Florian WilhelmFlorian Wilhelm
Florian Wilhelm
authored and
Florian Wilhelm
committed
Added some example timeseries
1 parent 3739ce6 commit 677c3cc

14 files changed

+1349
-12
lines changed

COPYING

+12
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,15 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2727
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
2929
DAMAGE.
30+
31+
-------------------------------------------------------------------------------
32+
33+
The time series data provided by PyDSE in the pydse/data folder are subject
34+
to the "default open license" of DataMarket (http://datamarket.com/):
35+
36+
Licence summary
37+
You may copy and redistribute the data. You may make derivative works from the
38+
data. You may use the data for commercial purposes. You may not sublicence the
39+
data when redistributing it. You may not redistribute the data under a
40+
different license. Source attribution on any use of this data: Must refer
41+
source.

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
include versioneer.py
22
include *.txt
33
include *.rst
4+
include pydse/data/*.csv
45
recursive-include pydse *.py *.c *.h *.pxd *.pyx
56
recursive-include docs *.rst *.py

pydse/arma.py

+9-12
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,20 @@ def _get_num_non_consts(self):
6666

6767
@property
6868
def non_consts(self):
69-
A = self.A[~self.Aconst]
70-
B = self.B[~self.Bconst]
71-
C = self.C[~self.Cconst]
72-
return np.hstack([A, B, C])
69+
a = self.A[~self.Aconst]
70+
b = self.B[~self.Bconst]
71+
c = self.C[~self.Cconst]
72+
return np.hstack([a, b, c])
7373

7474
@non_consts.setter
7575
def non_consts(self, values):
76-
a, b, c = self._get_num_non_consts()
77-
if values.size != a + b + c:
76+
parts = np.cumsum(self._get_num_non_consts())
77+
if values.size != parts[2]:
7878
raise ARMAError("Number of values does not equal number "
7979
"of non-constants")
80-
A_values = values[:a]
81-
B_values = values[a:a + b]
82-
C_values = values[a + b:a + b + c]
83-
self.A[~self.Aconst] = A_values
84-
self.B[~self.Bconst] = B_values
85-
self.C[~self.Cconst] = C_values
80+
self.A[~self.Aconst] = values[:parts[0]]
81+
self.B[~self.Bconst] = values[parts[0]:parts[1]]
82+
self.C[~self.Cconst] = values[parts[1]:parts[2]]
8683

8784
def _check_consistency(self, A, B, C, TREND):
8885
if A is None:

pydse/data/__init__.py

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# -*- encoding: utf-8 -*-
2+
3+
"""
4+
Example data files taken from DataMarket (http://datamarket.com/).
5+
Data is under the default open license:
6+
http://datamarket.com/data/license/0/default-open-license.html
7+
"""
8+
9+
from __future__ import division, print_function, absolute_import
10+
11+
import os
12+
import inspect
13+
import numpy as np
14+
import pandas as pd
15+
16+
__author__ = "Florian Wilhelm"
17+
__copyright__ = "Blue Yonder"
18+
__license__ = "new BSD"
19+
20+
__location__ = os.path.join(
21+
os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe())))
22+
23+
24+
def _get_df_from_file(filename):
25+
path = os.path.join(__location__, filename)
26+
return pd.DataFrame.from_csv(path, sep=";")
27+
28+
29+
def airline_passengers():
30+
"""
31+
Monthly totals of international airline passengers in thousands,
32+
Jan 1949 - Dec 1960
33+
"""
34+
return _get_df_from_file("international-airline-passengers.csv")
35+
36+
37+
def m1_us():
38+
"""
39+
Monthly M1 U.S., Jan 1959 - Feb 1992
40+
"""
41+
return _get_df_from_file("m1-us-1959119922.csv")
42+
43+
44+
def cpi_canada():
45+
"""
46+
Monthly CPI, Canada, Jan 1950 - Dec 1973
47+
"""
48+
return _get_df_from_file("monthly-cpi-canada-19501973.csv")
49+
50+
51+
def sales_product():
52+
"""
53+
Monthly sales of a plastic manufacturer'product, Jan 2001 - May 2012
54+
"""
55+
return _get_df_from_file("monthly-sales-of-product-a-for-a.csv")
56+
57+
58+
def sales_cola():
59+
"""
60+
Monthly sales of Tasty Cola, Jan 2001 - Mar 2012
61+
"""
62+
return _get_df_from_file("monthly-sales-of-tasty-cola.csv")
63+
64+
65+
def sales_shampoo():
66+
"""
67+
Monthly sales of shampoo, Jan 2001 - Mar 2012
68+
"""
69+
return _get_df_from_file("sales-of-shampoo-over-a-three-ye.csv")
70+
71+
72+
def sales_petroleum():
73+
"""
74+
Monthly sales of petroleum and related products in the U.S.,
75+
Jan 1971 - Dec 1991
76+
"""
77+
return _get_df_from_file("us-monthly-sales-of-petroleum-an.csv")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
"Month";"Passengers"
2+
"1949-01";112
3+
"1949-02";118
4+
"1949-03";132
5+
"1949-04";129
6+
"1949-05";121
7+
"1949-06";135
8+
"1949-07";148
9+
"1949-08";148
10+
"1949-09";136
11+
"1949-10";119
12+
"1949-11";104
13+
"1949-12";118
14+
"1950-01";115
15+
"1950-02";126
16+
"1950-03";141
17+
"1950-04";135
18+
"1950-05";125
19+
"1950-06";149
20+
"1950-07";170
21+
"1950-08";170
22+
"1950-09";158
23+
"1950-10";133
24+
"1950-11";114
25+
"1950-12";140
26+
"1951-01";145
27+
"1951-02";150
28+
"1951-03";178
29+
"1951-04";163
30+
"1951-05";172
31+
"1951-06";178
32+
"1951-07";199
33+
"1951-08";199
34+
"1951-09";184
35+
"1951-10";162
36+
"1951-11";146
37+
"1951-12";166
38+
"1952-01";171
39+
"1952-02";180
40+
"1952-03";193
41+
"1952-04";181
42+
"1952-05";183
43+
"1952-06";218
44+
"1952-07";230
45+
"1952-08";242
46+
"1952-09";209
47+
"1952-10";191
48+
"1952-11";172
49+
"1952-12";194
50+
"1953-01";196
51+
"1953-02";196
52+
"1953-03";236
53+
"1953-04";235
54+
"1953-05";229
55+
"1953-06";243
56+
"1953-07";264
57+
"1953-08";272
58+
"1953-09";237
59+
"1953-10";211
60+
"1953-11";180
61+
"1953-12";201
62+
"1954-01";204
63+
"1954-02";188
64+
"1954-03";235
65+
"1954-04";227
66+
"1954-05";234
67+
"1954-06";264
68+
"1954-07";302
69+
"1954-08";293
70+
"1954-09";259
71+
"1954-10";229
72+
"1954-11";203
73+
"1954-12";229
74+
"1955-01";242
75+
"1955-02";233
76+
"1955-03";267
77+
"1955-04";269
78+
"1955-05";270
79+
"1955-06";315
80+
"1955-07";364
81+
"1955-08";347
82+
"1955-09";312
83+
"1955-10";274
84+
"1955-11";237
85+
"1955-12";278
86+
"1956-01";284
87+
"1956-02";277
88+
"1956-03";317
89+
"1956-04";313
90+
"1956-05";318
91+
"1956-06";374
92+
"1956-07";413
93+
"1956-08";405
94+
"1956-09";355
95+
"1956-10";306
96+
"1956-11";271
97+
"1956-12";306
98+
"1957-01";315
99+
"1957-02";301
100+
"1957-03";356
101+
"1957-04";348
102+
"1957-05";355
103+
"1957-06";422
104+
"1957-07";465
105+
"1957-08";467
106+
"1957-09";404
107+
"1957-10";347
108+
"1957-11";305
109+
"1957-12";336
110+
"1958-01";340
111+
"1958-02";318
112+
"1958-03";362
113+
"1958-04";348
114+
"1958-05";363
115+
"1958-06";435
116+
"1958-07";491
117+
"1958-08";505
118+
"1958-09";404
119+
"1958-10";359
120+
"1958-11";310
121+
"1958-12";337
122+
"1959-01";360
123+
"1959-02";342
124+
"1959-03";406
125+
"1959-04";396
126+
"1959-05";420
127+
"1959-06";472
128+
"1959-07";548
129+
"1959-08";559
130+
"1959-09";463
131+
"1959-10";407
132+
"1959-11";362
133+
"1959-12";405
134+
"1960-01";417
135+
"1960-02";391
136+
"1960-03";419
137+
"1960-04";461
138+
"1960-05";472
139+
"1960-06";535
140+
"1960-07";622
141+
"1960-08";606
142+
"1960-09";508
143+
"1960-10";461
144+
"1960-11";390
145+
"1960-12";432

0 commit comments

Comments
 (0)