ds_common_placeholder_py_lib.functions.tables¶
File: functions/tables.py
Region: ds-common-placeholder-py-lib
Description¶
Functions over tables and plain values, as ds-workflow-manager’s builtins
behave. A table is a JSON array of objects, or a pandas DataFrame. The
package does not import pandas: a frame is recognised by its interface, and
read through it without converting the whole frame.
Attributes¶
Functions¶
|
value as plain JSON where a table library left its own types: numpy |
|
The distinct values of a column, in the order they first appear (as |
|
The value at row index and column. For a DataFrame the index is |
|
A DataFrame's rows as objects, column labels as text (as the other |
|
The table's rows as a JSON array, in a string: compact, non-ASCII |
|
Parse a JSON text. |
Module Contents¶
- ds_common_placeholder_py_lib.functions.tables.json_value(value: Any) Any[source]¶
value as plain JSON where a table library left its own types: numpy values as Python ones (arrays as lists), a missing value (
NaN,NaT,pd.NA) or an infinite number asNone, a timestamp as ISO 8601, aDecimalas a number. Anything else is returned as it is, and the caller checks that it is JSON.
- ds_common_placeholder_py_lib.functions.tables.get_column_as_list(args: list[Any]) list[Any][source]¶
The distinct values of a column, in the order they first appear (as the manager’s builtin does).
- Raises:
MissingValue – For an empty table or no such column (
missing_value;coalesceskips it).PlaceholderError –
typeif the table is not one.
- ds_common_placeholder_py_lib.functions.tables.get_value_from_dataframe(args: list[Any]) Any[source]¶
The value at row index and column. For a DataFrame the index is its row label (as the manager’s builtin reads it), for an array the position.
- Raises:
MissingValue – For an empty table, no such row or column (
missing_value;coalesceskips it).PlaceholderError –
argumentif index is not an integer or the frame’s row labels are not unique or not single-level.
- ds_common_placeholder_py_lib.functions.tables.frame_rows(table: Any) list[dict[str, Any]][source]¶
A DataFrame’s rows as objects, column labels as text (as the other functions address them; unique:
_table).
- ds_common_placeholder_py_lib.functions.tables.dataframe_to_json_array(args: list[Any]) str[source]¶
The table’s rows as a JSON array, in a string: compact, non-ASCII escaped, a missing value as
null. A DataFrame and an array of the same rows give the same text.- Raises:
MissingValue – For no value (
missing_value).PlaceholderError –
typeif it is not a table, or a cell is not JSON.
- ds_common_placeholder_py_lib.functions.tables.json_parse(args: list[Any]) Any[source]¶
Parse a JSON text.
- Raises:
MissingValue – For no value (
missing_value).PlaceholderError –
typeif the value is not a string,argumentif it is not JSON.
- ds_common_placeholder_py_lib.functions.tables.is_empty¶
- ds_common_placeholder_py_lib.functions.tables.is_string_empty¶
- ds_common_placeholder_py_lib.functions.tables.is_list_empty¶
- ds_common_placeholder_py_lib.functions.tables.is_dict_empty¶
- ds_common_placeholder_py_lib.functions.tables.is_dataframe_empty¶