Skip to content

Commit

Permalink
[python] update_obs/update_var with originhal or readback source
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Sep 26, 2023
1 parent 503ddd1 commit 08f6c8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion apis/python/src/tiledbsoma/io/_registration/signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ def _string_dict_from_pandas_dataframe(
df = df.head(1) # since reset_index can be expensive on full data
if df.index.name is None or df.index.name == "index":
df.reset_index(inplace=True)
df.rename(columns={"index": default_index_name}, inplace=True)
if default_index_name in df:
if "index" in df:
df.drop(columns=["index"], inplace=True)
else:
df.rename(columns={"index": default_index_name}, inplace=True)
else:
df.reset_index(inplace=True)

Expand Down
7 changes: 5 additions & 2 deletions apis/python/src/tiledbsoma/io/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,8 +1131,11 @@ def _write_dataframe(

df.reset_index(inplace=True)
if id_column_name is not None:
df.rename(columns={"index": id_column_name}, inplace=True)
id_column_name = "index"
if id_column_name in df:
if "index" in df:
df.drop(columns=["index"], inplace=True)
else:
df.rename(columns={"index": id_column_name}, inplace=True)

df[SOMA_JOINID] = np.asarray(axis_mapping.data)

Expand Down

0 comments on commit 08f6c8c

Please sign in to comment.