Skip to content

Commit 50fd5c2

Browse files
authored
KeyError fix issue #423 (#428)
* keyerror fix * nox fix
1 parent 8c392be commit 50fd5c2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ehrapy/anndata/anndata_ext.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ def _move_columns_to_obs(df: pd.DataFrame, columns_obs_only: list[str] | None) -
108108
obs = df[columns_obs_only].copy()
109109
obs = obs.set_index(df.index.map(str))
110110
df = df.drop(columns_obs_only, axis=1)
111-
except KeyError:
112-
raise ColumnNotFoundError from KeyError(
111+
except KeyError as e:
112+
raise ColumnNotFoundError(
113113
"One or more column names passed to column_obs_only were not found in the input data. "
114114
"Are the column names spelled correctly?"
115-
)
115+
) from e
116116
else:
117117
obs = pd.DataFrame(index=df.index.map(str))
118118
logg.info("Added all columns to `obs`.")

0 commit comments

Comments
 (0)