Table::update
and Table::remove
Once a Table
has been created, it can be updated with new data conforming to
the Table
's schema. Table::update
supports the same data formats as
Client::table
, minus schema.
const schema = {
a: "integer",
b: "float",
};
const table = await perspective.table(schema);
table.update(new_data);
schema = {"a": "integer", "b": "float"}
table = perspective.Table(schema)
table.update(new_data)
Without an index
set, calls to update()
append new data to the end of the
Table
. Otherwise, Perspective allows
partial updates (in-place) using the index
to determine
which rows to update:
indexed_table.update({ id: [1, 4], name: ["x", "y"] });
indexed_table.update({"id": [1, 4], "name": ["x", "y"]})
Any value on a Client::table
can be unset using the value null
in JSON or
Arrow input formats. Values may be unset on construction, as any null
in the
dataset will be treated as an unset value. Table::update
calls do not need to
provide all columns in the Table
's schema; missing columns will be omitted
from the Table
's updated rows.
table.update([{ x: 3, y: null }]); // `z` missing
table.update([{"x": 3, "y": None}]) // `z` missing
Rows can also be removed from an indexed Table
, by calling Table::remove
with an array of index values:
indexed_table.remove([1, 4]);
// Python
indexed_table.remove([1, 4])