tiledbsoma.io.update_obs¶
- tiledbsoma.io.update_obs(exp: Experiment, new_data: DataFrame, *, context: SOMATileDBContext | None = None, platform_config: Dict[str, Mapping[str, Any]] | object | None = None, default_index_name: str = 'obs_id') None¶
Replaces the entire
obsDataFrame with the contents of a new pandas DataFrame.This function is designed to perform a full replacement of the
obsDataFrame. It assumes the inputnew_dataDataFrame represents the desired final state for theobsSOMA DataFrame. The operation implicitly relies on row order for alignment.Details: * Schema Changes: Columns present in
new_databut not in the existingobswill be added. Columns presentin the existing
obsbut 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
obsDataFrame. 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
obsDataFrame 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_obs’snew_dataargument.
- Parameters:
exp – The
SOMAExperimentwhoseobsis to be updated. Must be opened for write.new_data – A pandas DataFrame containing the final desired data for the obs 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.