Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/statsmodels/datasets/sunspots/data.py : 65%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""Yearly sunspots data 1700-2008"""
2from statsmodels.datasets import utils as du
4__docformat__ = 'restructuredtext'
6COPYRIGHT = """This data is public domain."""
7TITLE = __doc__
8SOURCE = """
9http://www.ngdc.noaa.gov/stp/solar/solarda3.html
11The original dataset contains monthly data on sunspot activity in the file
12./src/sunspots_yearly.dat. There is also sunspots_monthly.dat.
13"""
15DESCRSHORT = """Yearly (1700-2008) data on sunspots from the National
16Geophysical Data Center."""
18DESCRLONG = DESCRSHORT
20NOTE = """::
22 Number of Observations - 309 (Annual 1700 - 2008)
23 Number of Variables - 1
24 Variable name definitions::
26 SUNACTIVITY - Number of sunspots for each year
28 The data file contains a 'YEAR' variable that is not returned by load.
29"""
32def load_pandas():
33 data = _get_data()
34 # TODO: time series
35 endog = data.set_index(data.YEAR).SUNACTIVITY
36 dataset = du.Dataset(data=data, names=list(data.columns),
37 endog=endog, endog_name='volume')
38 return dataset
41def load(as_pandas=None):
42 """
43 Load the yearly sunspot data and returns a data class.
45 Parameters
46 ----------
47 as_pandas : bool
48 Flag indicating whether to return pandas DataFrames and Series
49 or numpy recarrays and arrays. If True, returns pandas.
51 Returns
52 -------
53 Dataset instance:
54 See DATASET_PROPOSAL.txt for more information.
56 Notes
57 -----
58 This dataset only contains data for one variable, so the attributes
59 data, raw_data, and endog are all the same variable. There is no exog
60 attribute defined.
61 """
62 return du.as_numpy_dataset(load_pandas(), as_pandas=as_pandas)
65def _get_data():
66 return du.load_csv(__file__, 'sunspots.csv').astype(float)