iode.Database.__getitem__

Note

Below, Database represents either:

  • Comments

  • Equations

  • Identities

  • Lists

  • Scalars

  • Tables

  • Variables

Database.__getitem__()

Return the (subset of) IODE object(s) referenced by key.

The key can represent a single object name (e.g. “ACAF”) or a list of object names (“ACAF;ACAG;AOUC”) or a pattern (e.g. “A*”) or a list of sub-patterns (e.g. “A*;*_”).

If the key represents a list of object names or of sub-patterns, each name or sub-pattern is separated by a separator character which is either a whitespace ` , or a comma `,, or a semi-colon ;, or a tabulation t, or a newline n.

A (sub-)`pattern` is a list of characters representing a group of object names. It includes some special characters which have a special meaning:

  • * : any character sequence, even empty

  • ? : any character (one and only one)

  • @ : any alphanumerical char [A-Za-z0-9]

  • & : any non alphanumerical char

  • | : any alphanumeric character or none at the beginning and end of a string

  • ! : any non-alphanumeric character or none at the beginning and end of a string

  • `` : escape the next character

Note that the key can contain references to IODE lists which are prefixed with the symbol $.

Parameters:
key: str or list(str)

(the list of) name(s) of the IODE object(s) to get. The list of objects to get can be specified by a pattern or by a list of sub-patterns (e.g. “A*;*_”).

Returns:
Single IODE object or a subset of the database.

Examples

>>> from iode import SAMPLE_DATA_DIR

Comments

>>> from iode import comments
>>> comments.load(f"{SAMPLE_DATA_DIR}/fun.cmt")
>>> # a) get one Comment
>>> comments["ACAF"]
'Ondernemingen: ontvangen kapitaaloverdrachten.'
>>> # b) get a subset of the Comments database using a pattern
>>> comments_subset = comments["A*"]
>>> comments_subset.names
['ACAF', 'ACAG', 'AOUC', 'AQC']
>>> # c) get a subset of the Comments database using a list of names
>>> comments_subset = comments[["ACAF", "AOUC", "BQY", "BVY"]]
>>> comments_subset.names
['ACAF', 'AOUC', 'BQY', 'BVY']

Equations

>>> from iode import equations
>>> equations.load(f"{SAMPLE_DATA_DIR}/fun.eqs")
>>> # a) get one Equation
>>> equations["ACAF"]                  
Equation(endogenous = 'ACAF',
         lec = '(ACAF/VAF[-1]) :=acaf1+acaf2*GOSF[-1]+\nacaf4*(TIME=1995)',
         method = 'LSQ',
         from_period = '1980Y1',
         to_period = '1996Y1',
         block = 'ACAF',
         tests = {corr = 1,
                  dw = 2.32935,
                  fstat = 32.2732,
                  loglik = 83.8075,
                  meany = 0.00818467,
                  r2 = 0.821761,
                  r2adj = 0.796299,
                  ssres = 5.19945e-05,
                  stderr = 0.00192715,
                  stderrp = 23.5458,
                  stdev = 0.0042699},
         date = '12-06-1998')
>>> # b) get a subset of the Equations database using a pattern
>>> equations_subset = equations["A*"]
>>> equations_subset.names
['ACAF', 'ACAG', 'AOUC']
>>> # c) get a subset of the Equations database using a list of names
>>> equations_subset = equations[["ACAF", "AOUC", "BQY", "BVY"]]
>>> equations_subset.names
['ACAF', 'AOUC', 'BQY', 'BVY']

Identities

>>> from iode import identities
>>> identities.load(f"{SAMPLE_DATA_DIR}/fun.idt")
>>> # a) get one identities
>>> identities["AOUC"]
'((WCRH/QL)/(WCRH/QL)[1990Y1])*(VAFF/(VM+VAFF))[-1]+PM*(VM/(VM+VAFF))[-1]'
>>> # b) get a subset of the Identities database using a pattern
>>> identities_subset = identities["X*"]
>>> identities_subset.names
['XEX', 'XNATY', 'XPOIL', 'XPWMAB', 'XPWMS', 'XPWXAB', 'XPWXS', 'XQWXAB', 'XQWXS', 'XQWXSS', 'XRLBER', 'XTFP', 'XW']
>>> # c) get a subset of the Identities database using a list of names
>>> identities_subset = identities[["XEX", "XPWMAB", "XPWMS", "XQWXS", "XTFP"]]
>>> identities_subset.names
['XEX', 'XPWMAB', 'XPWMS', 'XQWXS', 'XTFP']

Lists

>>> from iode import lists
>>> lists.load(f"{SAMPLE_DATA_DIR}/fun.lst")
>>> # a) get one lists
>>> lists["ENVI"]
['EX', 'PWMAB', 'PWMS', 'PWXAB', 'PWXS', 'QWXAB', 'QWXS', 'POIL', 'NATY', 'TFPFHP_']
>>> # b) get a subset of the Lists database using a pattern
>>> lists_subset = lists["E*"]
>>> lists_subset.names
['ENDO', 'ENDO0', 'ENDO1', 'ENVI']
>>> # c) get a subset of the Lists database using a list of names
>>> lists_subset = lists[["COPY", "ENDO", "ENVI", "TOTAL"]]
>>> lists_subset.names
['COPY', 'ENDO', 'ENVI', 'TOTAL']

Scalars

>>> from iode import scalars
>>> scalars.load(f"{SAMPLE_DATA_DIR}/fun.scl")
>>> # a) get one scalars
>>> acaf1 = scalars["acaf1"]
>>> acaf1
Scalar(0.0157684, 1, 0.00136871)
>>> acaf1.value
0.01576840691268444
>>> acaf1.relax
1.0
>>> acaf1.std
0.0013687137980014086
>>> # b) get a subset of the Scalars database using a pattern
>>> scalars_subset = scalars["a*"]
>>> scalars_subset.names
['acaf1', 'acaf2', 'acaf3', 'acaf4']
>>> # c) get a subset of the Scalars database using a list of names
>>> scalars_subset = scalars[["acaf1", "acaf4", "dpuh_1", "dpuh_2"]]
>>> scalars_subset.names
['acaf1', 'acaf4', 'dpuh_1', 'dpuh_2']

Tables

>>> from iode import tables
>>> tables.load(f"{SAMPLE_DATA_DIR}/fun.tbl")
>>> # a) get one tables
>>> tables["YDH"]           
DIVIS |                                                          1 |                                    PC_*40.34
TITLE |                        "Tableau B-3. Revenu disponible des ménages à prix constant"
----- | ---------------------------------------------------------------------------------------------------------
CELL  |                                                            |                     "#S"
CELL  | "Revenus primaires"                                        |                            WBU_+YN+GOSH_+IDH
CELL  | "   Masse salariale totale"                                |                                         WBU_
CELL  | "   Revenu net du travail en provenance du Reste du monde" |                                           YN
CELL  | "   Surplus brut d'exploitation"                           |                                        GOSH_
CELL  | "   Revenu net de la propriété"                            |                                          IDH
CELL  | "Cotisations sociales et impôts"                           |                                  SSF+SSH+DTH
CELL  | "   Cotisations patronales"                                |                                          SSF
CELL  | "   Cotisations personnelles"                              |                                          SSH
CELL  | "IPP"                                                      |                                          DTH
CELL  | "Prestations sociales "                                    |                                     SBH+OCUH
CELL  | "   Sécurité sociale"                                      |                                          SBH
CELL  | "   Diverses prestations"                                  |                                         OCUH
CELL  | "Total"                                                    | (WBU_+YN+GOSH_+IDH)-(SSF+SSH+DTH)+(SBH+OCUH)
----- | ---------------------------------------------------------------------------------------------------------
FILES |
DATE  |

nb lines: 19
nb columns: 2
language: 'ENGLISH'
gridx: 'MAJOR'
gridy: 'MAJOR'
graph_axis: 'VALUES'
graph_alignment: 'LEFT'
        
>>> # b) get a subset of the Tables database using a pattern
>>> tables_subset = tables["C8_*"]
>>> tables_subset.names
['C8_1', 'C8_10', 'C8_11', 'C8_13', 'C8_14', 'C8_2', 'C8_3', 'C8_4', 'C8_5', 'C8_6', 'C8_7', 'C8_8', 'C8_9']
>>> # c) get a subset of the Tables database using a list of names
>>> tables_subset = tables[["C8_1", "C8_2", "C8_4", "C8_5", "C8_7"]]
>>> tables_subset.names
['C8_1', 'C8_2', 'C8_4', 'C8_5', 'C8_7']

Variables

>>> from iode import variables, NA
>>> variables.load(f"{SAMPLE_DATA_DIR}/fun.var")
>>> variables.sample
'1960Y1:2015Y1'
>>> # -------- a) get one Variable --------
>>> # get the variable values for the whole sample
>>> variables["ACAF"]                       
[-2e+37, -2e+37, ..., -83.34062511080091, -96.41041982848331]
>>> # get the variable value for a specific period
>>> variables["ACAF", "1990Y1"]
23.771
>>> # get the variable values for range of periods (using a Python slice)
>>> variables["ACAF", "1990Y1":"2000Y1"]    
[23.771, 26.240999, ..., 13.530404919696034, 10.046610792200543]
>>> # same as above but with the colon ':' inside the periods range string
>>> variables["ACAF", "1990Y1:2000Y1"]      
[23.771, 26.240999, ..., 13.530404919696034, 10.046610792200543]
>>> # b) -------- get a subset of the Variables database using a pattern --------
>>> variables_subset = variables["A*"]
>>> variables_subset.names
['ACAF', 'ACAG', 'AOUC', 'AOUC_', 'AQC']
>>> # get the variable values for a specific period
>>> variables["A*", "1990Y1"]
[23.771, -28.1721855713507, 1.0, 0.9373591502749314, 1.0]
>>> # get the variable values for range of periods (using a Python slice)
>>> variables["A*", "1990Y1":"2000Y1"]      
[[23.771, 26.240999, 30.159, ..., 1.2031082, 1.3429699656745855, 1.3386028553645442]]
>>> # c) -------- get a subset of the Variables database using a list of names --------
>>> variables_subset = variables[["ACAF", "ACAG", "AQC", "BQY", "BVY"]]
>>> variables_subset.names
['ACAF', 'ACAG', 'AQC', 'BQY', 'BVY']
>>> # get the variable values for a specific period
>>> variables[["ACAF", "ACAG", "AQC", "BQY", "BVY"], "1990Y1"]
[23.771, -28.1721855713507, 1.0, -34.099998, -34.099997]
>>> # get the variable values for range of periods (using a Python slice)
>>> variables[["ACAF", "ACAG", "AQC", "BQY", "BVY"], "1990Y1":"2000Y1"]      
[[23.771, 26.240999, 30.159, ..., 140.73978, 144.8587818455608, 150.05335230584103]]