4.4.4. Table¶
Tables are used to report 2-entries tables.
The row-major-order convention is selected for Table. This means that the records are reported row-by-row, as opposed to column-by-column.
4.4.4.1. Example Table¶
The example below reports a table of records of time, pressure and temperature, as in:
Time |
Pressure |
Temperature |
---|---|---|
2032-04-23T10:20:30.400+02:30 |
150 |
25.5 |
2032-04-23T10:20:30.500+02:30 |
160 |
25.3 |
2032-04-23T10:20:30.600+02:3 |
170 |
25.1 |
In PDEF, such a table is serialized as follow:
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 31 32 33 34 35 36 37 38 39 | {
"headers": [
{
"name": "ts",
"title": "Time",
"description": "Time stamp for the records.",
"unit": "time"
},
{
"name": "p",
"title": "Pressure",
"description": "Internal pressure gauge records",
"unit": "bar"
},
{
"name": "t",
"title": "Temperature",
"description": "Temperature gauge records",
"unit": "C"
}
],
"data": [
{
"ts": "2032-04-23T10:20:30.400+02:30",
"p": 150,
"t": 25.5
},
{
"ts": "2032-04-23T10:20:30.500+02:30",
"p": 160,
"t": 25.3
},
{
"ts": "2032-04-23T10:20:30.500+02:30",
"p": 170,
"t": 25.1
}
]
}
|
Warning
Note how the name attributes of the header objects are used to map the data
Note
The Header objects provide context and explicit description of the series (columns).
4.4.4.2. Schema Table¶
-
pdef.model.table.
Table
Table bundle one or several series. Series are similar to columns in row-major-order.
Show JSON schema
{ "title": "Table", "description": ":ref:`Table` bundle one or several series. Series are similar to columns in row-major-order.", "type": "object", "properties": { "headers": { "title": "Headers", "description": "The array of :ref:`Header` objects describing the series.", "name": "fields", "type": "array", "items": { "$ref": "#/definitions/Header" } }, "data": { "title": "Data", "description": "The records, similar to rows in row-major-order. The key of the objects MUST be the name declared in the :ref:`Header`.", "name": "data", "type": "array", "items": { "type": "object" } } }, "required": [ "headers", "data" ], "additionalProperties": false, "definitions": { "Header": { "title": "Header", "description": ":ref:`Header` captures context and meta information about a series. This is similar to the header of a column.", "type": "object", "properties": { "name": { "title": "Name", "description": "Short name, usually very abbreviated. This name MUST be re-used as key in the data objects.", "example": "p", "type": "string" }, "title": { "title": "Title", "description": "Title to be given to the series.", "example": "Pressure", "type": "string" }, "description": { "title": "Description", "description": "Descriptive text about the series.", "example": "Internal pressure gauge record", "type": "string" }, "unit": { "title": "unit of measure", "description": "Unit of measure.", "type": "string" } }, "required": [ "unit" ] } } }
- Config
extra: str = forbid
-
data
: List[Dict] = Ellipsis The records, similar to rows in row-major-order. The key of the objects MUST be the name declared in the Header.
- Constraints and examples:
name = data
-
headers
: List[pdef.model.table.Header] = Ellipsis The array of Header objects describing the series.
- Constraints and examples:
name = fields
4.4.4.3. Header¶
4.4.4.3.1. Example Header¶
1 2 3 4 5 6 | {
"name": "ts",
"title": "Time",
"description": "Time stamp for the records.",
"unit": "time"
}
|
4.4.4.3.2. Schema Header¶
-
pdef.model.table.
Header
Header captures context and meta information about a series. This is similar to the header of a column.
Show JSON schema
{ "title": "Header", "description": ":ref:`Header` captures context and meta information about a series. This is similar to the header of a column.", "type": "object", "properties": { "name": { "title": "Name", "description": "Short name, usually very abbreviated. This name MUST be re-used as key in the data objects.", "example": "p", "type": "string" }, "title": { "title": "Title", "description": "Title to be given to the series.", "example": "Pressure", "type": "string" }, "description": { "title": "Description", "description": "Descriptive text about the series.", "example": "Internal pressure gauge record", "type": "string" }, "unit": { "title": "unit of measure", "description": "Unit of measure.", "type": "string" } }, "required": [ "unit" ] }
-
description
: Optional[str] = PydanticUndefined Descriptive text about the series.
- Constraints and examples:
example = Internal pressure gauge record
-
name
: Optional[str] = PydanticUndefined Short name, usually very abbreviated. This name MUST be re-used as key in the data objects.
- Constraints and examples:
example = p
-
title
: Optional[str] = PydanticUndefined Title to be given to the series.
- Constraints and examples:
example = Pressure
-
unit
: Optional[str] = Ellipsis Unit of measure.
-