iode.ComputedTable.__getitem__

ComputedTable.__getitem__(key: Tuple[int | str, int | str]) float[source]

Get the value of a cell of the computed table.

Parameters:
key: tuple(int or str, int or str) or int or str

Row and column of the cell to access. Row and column can be passed either as position (int) or as name (str).

Returns:
float:

The value of a given cell.

Examples

>>> from iode import SAMPLE_DATA_DIR
>>> from iode import Table, comments, variables
>>> comments.load(f"{SAMPLE_DATA_DIR}/fun.cmt")
Loading .../fun.cmt
317 objects loaded 
>>> variables.load(f"{SAMPLE_DATA_DIR}/fun.var")
Loading .../fun.var
394 objects loaded
>>> title = "Example Table"
>>> lecs = ["Q_F", "Q_I", "Q_F/Q_I", "ln(Q_I+Q_F)", "KNFF", "KNFF[-1]", "3+ln(10)", "0+KNFF"]
>>> table = Table(2, title, lecs)
>>> table
DIVIS | 1             |
TITLE |       "Example Table"
----- | ---------------------------
CELL  |               |     "#S"
----- | ---------------------------
CELL  | "Q_F"         |         Q_F
CELL  | "Q_I"         |         Q_I
CELL  | "Q_F/Q_I"     |     Q_F/Q_I
CELL  | "ln(Q_I+Q_F)" | ln(Q_I+Q_F)
CELL  | "KNFF"        |        KNFF
CELL  | "KNFF[-1]"    |    KNFF[-1]
CELL  | "3+ln(10)"    |    3+ln(10)
CELL  | "0+KNFF"      |      0+KNFF

nb lines: 12
nb columns: 2
language: 'ENGLISH'
gridx: 'MAJOR'
gridy: 'MAJOR'
graph_axis: 'VALUES'
graph_alignment: 'LEFT'
>>> # compute table
>>> computed_table = table.compute("(2010;2010/2009)[1;2]:2", extra_files=f"{SAMPLE_DATA_DIR}/ref.av")
>>> computed_table
 line title \ period[file]  | 2010[1]  | 2010[2]  | 2010/2009[1] | 2010/2009[2] | 2011[1]  | 2011[2]  | 2011/2010[1] | 2011/2010[2]
------------------------------------------------------------------------------------------------------------------------------------
Q_F                         |  5842.74 |  5725.89 |         1.90 |         1.90 |  5930.75 |  5812.13 |         1.51 |         1.51
Q_I                         |  1093.37 |  1071.50 |         0.89 |         0.89 |  1114.60 |  1092.30 |         1.94 |         1.94
Q_F/Q_I                     |     5.34 |     5.34 |         1.00 |         1.00 |     5.32 |     5.32 |        -0.43 |        -0.43
ln(Q_I+Q_F)                 |     8.84 |     8.82 |         0.20 |         0.20 |     8.86 |     8.84 |         0.18 |         0.18
KNFF                        | 11525.01 | 11294.51 |         2.05 |         2.05 | 11736.78 | 11502.05 |         1.84 |         1.84
KNFF[-1]                    | 11293.85 | 11067.97 |         2.82 |         2.82 | 11525.01 | 11294.51 |         2.05 |         2.05
3+ln(10)                    |     5.30 |     5.30 |         0.00 |         0.00 |     5.30 |     5.30 |         0.00 |         0.00
0+KNFF                      | 11525.01 | 11294.51 |         2.05 |         2.05 | 11736.78 | 11502.05 |         1.84 |         1.84
>>> # get cell value by position
>>> computed_table[2, 2]
0.9975986300775119
>>> # get cell value by labels
>>> computed_table["Q_F/Q_I", "2010/2009[1]"]
0.9975986300775119