Sequences

Metadata

AsyncCogniteClient.sequences.aggregate_cardinality_properties(path)

Find approximate paths count for sequences.

AsyncCogniteClient.sequences.aggregate_cardinality_values(...)

Find approximate property count for sequences.

AsyncCogniteClient.sequences.aggregate_count([...])

Count of sequences matching the specified filters and search.

AsyncCogniteClient.sequences.aggregate_unique_properties(path)

Find approximate unique sequence properties.

AsyncCogniteClient.sequences.aggregate_unique_values(...)

Get unique paths with counts for sequences.

AsyncCogniteClient.sequences.create(sequence)

Create one or more sequences.

AsyncCogniteClient.sequences.delete([id, ...])

Delete one or more sequences.

AsyncCogniteClient.sequences.list([name, ...])

List sequences.

AsyncCogniteClient.sequences.retrieve([id, ...])

Retrieve a single sequence by id.

AsyncCogniteClient.sequences.retrieve_multiple([...])

Retrieve multiple sequences by id.

AsyncCogniteClient.sequences.search([name, ...])

Search for sequences.

AsyncCogniteClient.sequences.update(item[, mode])

Update one or more sequences.

AsyncCogniteClient.sequences.upsert(item[, mode])

Upsert sequences, i.e., update if it exists, and create if it does not exist.

Rows

AsyncCogniteClient.sequences.data.delete(rows)

Delete rows from a sequence.

AsyncCogniteClient.sequences.data.delete_range(...)

Delete a range of rows from a sequence.

AsyncCogniteClient.sequences.data.insert(rows)

Insert rows into a sequence.

AsyncCogniteClient.sequences.data.insert_dataframe(...)

Insert a Pandas dataframe.

AsyncCogniteClient.sequences.data.retrieve([...])

Retrieve data from a sequence.

AsyncCogniteClient.sequences.data.retrieve_dataframe(...)

Retrieve data from a sequence as a pandas dataframe.

AsyncCogniteClient.sequences.data.retrieve_last_row([...])

Retrieves the last row (i.e the row with the highest row number) in a sequence.

Sequence Data classes

class cognite.client.data_classes.sequences.Sequence(
id: int,
created_time: int,
last_updated_time: int,
columns: Sequence[SequenceColumn] | SequenceColumnList,
name: str | None = None,
description: str | None = None,
asset_id: int | None = None,
external_id: str | None = None,
metadata: dict[str, Any] | None = None,
data_set_id: int | None = None,
)

Information about the sequence stored in the database. This is the read version of the class, it is used for retrieving data from the CDF.

Parameters:
  • id (int) – Unique cognite-provided identifier for the sequence

  • created_time (int) – Time when this sequence was created in CDF in milliseconds since Jan 1, 1970.

  • last_updated_time (int) – The last time this sequence was updated in CDF, in milliseconds since Jan 1, 1970.

  • columns (Sequence[SequenceColumn] | SequenceColumnList) – List of column definitions

  • name (str | None) – Name of the sequence

  • description (str | None) – Description of the sequence

  • asset_id (int | None) – Optional asset this sequence is associated with

  • external_id (str | None) – The external ID provided by the client. Must be unique for the resource type.

  • metadata (dict[str, Any] | None) – Custom, application-specific metadata. String key -> String value. The maximum length of the key is 32 bytes, the value 512 bytes, with up to 16 key-value pairs.

  • data_set_id (int | None) – Data set that this sequence belongs to

class cognite.client.data_classes.sequences.SequenceColumn(
external_id: str,
value_type: Literal['STRING', 'DOUBLE', 'LONG'],
created_time: int | None = None,
last_updated_time: int | None = None,
name: str | None = None,
description: str | None = None,
metadata: dict[str, Any] | None = None,
)

Bases: SequenceColumnCore

This represents a column in a sequence. It is used for reading only.

Parameters:
  • external_id (str) – The external ID provided by the client. Must be unique for the resource type.

  • value_type (ValueType) – The type of the column. It can be STRING, DOUBLE or LONG.

  • created_time (int | None) – Time when this column was created in CDF in milliseconds since Jan 1, 1970.

  • last_updated_time (int | None) – The last time this column was updated in CDF, in milliseconds since Jan 1, 1970.

  • name (str | None) – Name of the column

  • description (str | None) – Description of the column

  • metadata (dict[str, Any] | None) – Custom, application-specific metadata. String key -> String value. Maximum length of key is 32 bytes, value 512 bytes, up to 16 key-value pairs.

as_write() SequenceColumnWrite

Returns a writeable version of this column.

class cognite.client.data_classes.sequences.SequenceColumnCore(
external_id: str,
name: str | None,
description: str | None,
metadata: dict[str, Any] | None,
value_type: Literal['STRING', 'DOUBLE', 'LONG'] = 'DOUBLE',
)

Bases: WriteableCogniteResource[SequenceColumnWrite], ABC

This represents a column in a sequence.

Parameters:
  • external_id (str) – The external ID provided by the client. Must be unique for the resource type.

  • name (str | None) – Name of the column

  • description (str | None) – Description of the column

  • metadata (dict[str, Any] | None) – Custom, application-specific metadata. String key -> String value. The maximum length of key is 32 bytes, value 512 bytes, up to 16 key-value pairs.

  • value_type (ValueType) – The type of the column. It can be STRING, DOUBLE or LONG.

class cognite.client.data_classes.sequences.SequenceColumnList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceList[SequenceColumn], ExternalIDTransformerMixin

as_write() SequenceColumnWriteList

Returns a writeable version of this column list.

property value_types: list[Literal['STRING', 'DOUBLE', 'LONG']]

Retrieves list of column value types

Returns:

List of column value types

Return type:

list[ValueType]

class cognite.client.data_classes.sequences.SequenceColumnUpdate(id: int | None = None, external_id: str | None = None)

Bases: CogniteUpdate

This class is used to update a sequence column.

class cognite.client.data_classes.sequences.SequenceColumnWrite(
external_id: str,
name: str | None = None,
description: str | None = None,
value_type: Literal['STRING', 'DOUBLE', 'LONG'] = 'DOUBLE',
metadata: dict[str, Any] | None = None,
)

Bases: SequenceColumnCore

This represents a column in a sequence. This is used for writing only.

Parameters:
  • external_id (str) – The external ID provided by the client. Must be unique for the resource type.

  • name (str | None) – Name of the column

  • description (str | None) – Description of the column

  • value_type (ValueType) – The type of the column. It can be STRING, DOUBLE or LONG.

  • metadata (dict[str, Any] | None) – Custom, application-specific metadata. String key -> String value. The maximum length of key is 32 bytes, value 512 bytes, up to 16 key-value pairs.

as_write() SequenceColumnWrite

Returns this SequenceColumnWrite.

class cognite.client.data_classes.sequences.SequenceColumnWriteList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceList[SequenceColumnWrite], ExternalIDTransformerMixin

property value_types: list[Literal['STRING', 'DOUBLE', 'LONG']]

Retrieves list of column value types

Returns:

List of column value types

Return type:

list[ValueType]

cognite.client.data_classes.sequences.SequenceDataList

alias of SequenceRowsList

class cognite.client.data_classes.sequences.SequenceFilter(
name: str | None = None,
external_id_prefix: str | None = None,
metadata: dict[str, Any] | None = None,
asset_ids: Sequence[int] | None = None,
asset_subtree_ids: Sequence[dict[str, Any]] | None = None,
created_time: dict[str, Any] | TimestampRange | None = None,
last_updated_time: dict[str, Any] | TimestampRange | None = None,
data_set_ids: Sequence[dict[str, Any]] | None = None,
)

Bases: CogniteFilter

No description.

Parameters:
  • name (str | None) – Return only sequences with this exact name.

  • external_id_prefix (str | None) – Filter by this (case-sensitive) prefix for the external ID.

  • metadata (dict[str, Any] | None) – Filter the sequences by metadata fields and values (case-sensitive). Format is {“key1”:”value1”,”key2”:”value2”}.

  • asset_ids (Sequence[int] | None) – Return only sequences linked to one of the specified assets.

  • asset_subtree_ids (Sequence[dict[str, Any]] | None) – Only include sequences that have a related asset in a subtree rooted at any of these assetIds. If the total size of the given subtrees exceeds 100,000 assets, an error will be returned.

  • created_time (dict[str, Any] | TimestampRange | None) – Range between two timestamps.

  • last_updated_time (dict[str, Any] | TimestampRange | None) – Range between two timestamps.

  • data_set_ids (Sequence[dict[str, Any]] | None) – Only include sequences that belong to these datasets.

class cognite.client.data_classes.sequences.SequenceList(
resources: Sequence[T_CogniteResource],
)

Bases: WriteableCogniteResourceList[SequenceWrite, Sequence], IdTransformerMixin

as_write() SequenceWriteList

Returns a writeable version of this sequence list.

class cognite.client.data_classes.sequences.SequenceProperty(value)

Bases: EnumProperty

An enumeration.

class cognite.client.data_classes.sequences.SequenceRow(row_number: int, values: Sequence[int | str | float | None])

Bases: CogniteResource

This class represents a row in a sequence. It is used for both read and write.

Parameters:
  • row_number (int) – The row number for this row.

  • values (Sequence[RowValues]) – List of values in the order defined in the columns field. Number of items must match. Null is accepted for missing values. String values must be no longer than 256 characters.

class cognite.client.data_classes.sequences.SequenceRows(
rows: Sequence[SequenceRow],
columns: SequenceColumnList,
id: int | None = None,
external_id: str | None = None,
)

Bases: CogniteResource

An object representing a list of rows from a sequence.

Parameters:
  • rows (Sequence[SequenceRow]) – The sequence rows.

  • columns (SequenceColumnList) – The column information.

  • id (int | None) – Identifier of the sequence the data belong to

  • external_id (str | None) – External id of the sequence the data belong to

property column_external_ids: list[str]

Retrieves list of column external ids for the sequence, for use in e.g. data retrieve or insert methods.

Returns:

List of sequence column external ids.

Return type:

list[str]

property column_value_types: list[Literal['STRING', 'DOUBLE', 'LONG']]

Retrieves list of column value types.

Returns:

List of column value types

Return type:

list[ValueType]

dump(camel_case: bool = True) dict[str, Any]

Dump the sequence data into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representing the instance.

Return type:

dict[str, Any]

get_column(external_id: str) list[int | str | float | None]

Get a column by external_id.

Parameters:

external_id (str) – External id of the column.

Returns:

A list of values for that column in the sequence

Return type:

list[RowValues]

items() Iterator[tuple[int, list[int | str | float | None]]]

Returns an iterator over tuples of (row number, values).

to_pandas(
column_names: ColumnNames = 'columnExternalId',
) pandas.DataFrame

Convert the sequence data into a pandas DataFrame.

Parameters:

column_names (ColumnNames) – Which field(s) to use as column header. Can use “externalId”, “id”, “columnExternalId”, “id|columnExternalId” or “externalId|columnExternalId”.

Returns:

The dataframe.

Return type:

pandas.DataFrame

property values: list[list[int | str | float | None]]

Returns a list of lists of values

class cognite.client.data_classes.sequences.SequenceRowsList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceList[SequenceRows], IdTransformerMixin

to_pandas(
key: Literal['id', 'external_id'] = 'external_id',
column_names: ColumnNames = 'externalId|columnExternalId',
concat: bool = False,
) pandas.DataFrame | dict[str, pandas.DataFrame] | dict[int, pandas.DataFrame]

Convert the sequence data list into a pandas DataFrame. Each column will be a sequence.

Parameters:
  • key (Literal['id', 'external_id']) – If concat = False, this decides which field to use as key in the dictionary. Defaults to “external_id”.

  • column_names (ColumnNames) – Which field to use as column header. Can use any combination of “externalId”, “columnExternalId”, “id” and other characters as a template.

  • concat (bool) – Whether to concatenate the sequences into a single DataFrame or return a dictionary of DataFrames. Defaults to False.

Returns:

The sequence data list as a pandas DataFrame.

Return type:

pandas.DataFrame | dict[str, pandas.DataFrame] | dict[int, pandas.DataFrame]

class cognite.client.data_classes.sequences.SequenceUpdate(id: int | None = None, external_id: str | None = None)

Bases: CogniteUpdate

No description.

Parameters:
  • id (int) – A server-generated ID for the object.

  • external_id (str) – The external ID provided by the client. Must be unique for the resource type.

class cognite.client.data_classes.sequences.SequenceWrite(
columns: SequenceColumnWriteList | Sequence[SequenceColumnWrite],
name: str | None = None,
description: str | None = None,
asset_id: int | None = None,
external_id: str | None = None,
metadata: dict[str, Any] | None = None,
data_set_id: int | None = None,
)

Bases: WriteableCogniteResource[SequenceWrite]

Information about the sequence stored in the database. This is the write version of the class, it is used for inserting data into the CDF.

Parameters:
  • columns (SequenceColumnWriteList | Sequence[SequenceColumnWrite]) – List of column definitions

  • name (str | None) – Name of the sequence

  • description (str | None) – Description of the sequence

  • asset_id (int | None) – Optional asset this sequence is associated with

  • external_id (str | None) – The external ID provided by the client. Must be unique for the resource type.

  • metadata (dict[str, Any] | None) – Custom, application-specific metadata. String key -> String value. Th maximum length of key is 32 bytes, value 512 bytes, up to 16 key-value pairs.

  • data_set_id (int | None) – Data set that this sequence belongs to

as_write() SequenceWrite

Returns this SequenceWrite.

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

class cognite.client.data_classes.sequences.SequenceWriteList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceList[SequenceWrite], ExternalIDTransformerMixin

class cognite.client.data_classes.sequences.SortableSequenceProperty(value)

Bases: EnumProperty

An enumeration.