Fix assignment to use loc.
For assigning a value to selected rows (a subset), regular slicing using [] produces a KeyError.communication
parent
a06ad0800f
commit
a2180aee54
|
@ -256,9 +256,9 @@ def clean_up_esm(df_esm_preprocessed: pd.DataFrame) -> pd.DataFrame:
|
|||
ESM.ESM_TYPE.get("scale"),
|
||||
ESM.ESM_TYPE.get("number"),
|
||||
]
|
||||
df_esm_clean[df_esm_clean["esm_type"].isin(esm_type_numeric)] = df_esm_clean[
|
||||
df_esm_clean.loc[
|
||||
df_esm_clean["esm_type"].isin(esm_type_numeric)
|
||||
].assign(
|
||||
] = df_esm_clean.loc[df_esm_clean["esm_type"].isin(esm_type_numeric)].assign(
|
||||
esm_user_answer_numeric=lambda x: x.esm_user_answer.str.slice(stop=1).astype(
|
||||
int
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue