Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt

Use this file to discover all available pages before exploring further.

property Table.keys : Sequence[str]

Names of the key columns of the table. When a table does not have keys, adding the same row twice will result in two identical rows in the table:
>>> table = session.create_table(
...     "No keys", data_types={"Product": "String", "Quantity": "int"}
... )
>>> table.keys
()
>>> table += ("Book", 42)
>>> table += ("Book", 42)
>>> table.row_count
2
>>> table.head().sort_index()
  Product  Quantity
0    Book        42
1    Book        42
The identical rows can be deleted:
>>> table.drop((table["Product"] == "Book") & (table["Quantity"] == 42))
>>> table.row_count
0
When a table has some keys, inserting a new row with key values equal to the ones of an existing row will overwrite the old row:
>>> table = session.create_table(
...     "Some keys",
...     data_types={
...         "Country": "String",
...         "City": "String",
...         "Year": "int",
...         "Population": "int",
...     },
...     keys={"Country", "City"},
... )
>>> table.keys
('Country', 'City')
>>> table += ("France", "Paris", 2000, 9_737_000)
>>> table += ("United States", "San Diego", 2000, 2_681_000)
>>> table.head().sort_index()
                         Year  Population
Country       City
France        Paris      2000     9737000
United States San Diego  2000     2681000
>>> table += ("France", "Paris", 2024, 11_277_000)
>>> table.head().sort_index()
                         Year  Population
Country       City
France        Paris      2024    11277000
United States San Diego  2000     2681000