Insert a pandas dataframe into a sequence

async AsyncCogniteClient.sequences.data.insert_dataframe(
dataframe: pd.DataFrame,
id: int | None = None,
external_id: str | None = None,
dropna: bool = True,
) → None

Insert a Pandas dataframe.

Deprecated since version 8.23.0: The Sequences API is deprecated and is scheduled for removal on 2027-12-31. Use files in data modeling (for whole-table downloads) or records (for row-level queries). See https://docs.cognite.com/cdf/deprecated for details and migration guidance.

The index of the dataframe must contain the row numbers. The names of the remaining columns specify the column external ids. The sequence and columns must already exist.

Parameters:
  • dataframe (pd.DataFrame) – Pandas DataFrame object containing the sequence data.

  • id (int | None) – Id of sequence to insert rows into.

  • external_id (str | None) – External id of sequence to insert rows into.

  • dropna (bool) – Whether to drop rows where all values are missing. Default: True.

Examples

Insert three rows into columns ‘col_a’ and ‘col_b’ of the sequence with id=123:

>>> from cognite.client import CogniteClient
>>> import pandas as pd
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> df = pd.DataFrame({"col_a": [1, 2, 3], "col_b": [4, 5, 6]}, index=[1, 2, 3])
>>> client.sequences.data.insert_dataframe(df, id=123)