Skip to main content
less.write_table(name, df) receives a Pandas DataFrame and stores it as a table in Less, and returns the id of the table it wrote.
By default this replaces the table your script owns under that name, creating it the first time the script runs. Table names are not unique in Less, so this lookup is limited to tables this Python asset created. Two assets can have tables with the same name and they will not collide.

Overwrite a specific table

Pass table_id to overwrite one particular table. This is how you write to a table that another asset created — a source, a model, or another Python script — without changing that original asset.
You can copy the id from Less, or look it up with List Tables:
You must have write access to the table. The original asset remains the owner. The existing table name is kept. name must match that table; if it does not, a warning is logged and the original name is used.

Append to an existing table

Pass append=True to union the new rows onto the rows already in the table rather than replacing them.
Without table_id, this appends to the table your script owns under name. Combine the two to append to a specific table, including one created by another asset:
Notes:
  • df must be a pandas DataFrame.
  • Empty DataFrames are skipped.
  • Appending to a table that does not exist yet simply creates it (only when table_id is not given).
  • Appending is a plain union: rows are stacked and any columns that appear on only one side are filled with nulls.