tiledbsoma.io.update_var¶
- tiledbsoma.io.update_var(exp: Experiment, new_data: DataFrame, measurement_name: str, *, context: SOMATileDBContext | None = None, platform_config: Dict[str, Mapping[str, Any]] | object | None = None, default_index_name: str = 'var_id') None¶
Replaces the entire
varDataFrame with the contents of a new pandas DataFrame.This function is designed to perform a full replacement of the
varDataFrame. It assumes the inputnew_dataDataFrame represents the desired final state for thevarSOMA DataFrame. The operation implicitly relies on row order for alignment.Details: * Schema Changes: Columns present in
new_databut not in the existingvarwill be added. Columns presentin the existing
varbut absent fromnew_datawill be dropped.- Row Alignment: The function requires that the input
`new_dataDataFrame has the exact same number of rows and order as the existing
varDataFrame. It does not perform a join based on user-defined cell IDs or other index columns.
- Row Alignment: The function requires that the input
To avoid data misalignment, the following workflow is recommended:
Read the entire existing
varDataFrame into memory.Perform all desired modifications (updating values, adding/dropping columns) on this DataFrame, preserving the original row order.
Pass the fully modified DataFrame to
update_var’snew_dataargument.
- Parameters:
exp – The
SOMAExperimentwhosevaris to be updated. Must be opened for write.new_data – A pandas DataFrame containing the final desired data for the var SOMA DataFrame.
context – Optional
SOMATileDBContextcontaining storage parameters, etc.platform_config – Platform-specific options used to update this array, provided in the form
{"tiledb": {"create": {"dataframe_dim_zstd_level": 7}}}default_index_name – What to call the
new_dataindex column if it is nameless in Pandas, or has name"index".
- Returns:
None
Lifecycle
Maturing.