When running the preprocessing pipeline (specifically in preprocess.py), the following error occurs:
Error processing configuration: Choicelist and default value do not have a common dtype: The DType <class 'numpy.dtypes._PyLongDType'> could not be promoted by <class 'numpy.dtypes.StrDType'>. This means that no common DType exists for the given inputs. For example they cannot be stored in a single array unless the dtype is `object`.
This happens at the line:
choicelist = feature_categories.keys()
df = df.assign(group=np.select(condlist, choicelist))
How to Fix
- Explicitly convert
feature_categories.keys() to a list of strings using list().
- Explicitly set the
default parameter in np.select to a string value (e.g., 'other'), ensuring all possible outputs are of the same type.
Solution
Change this code:
choicelist = feature_categories.keys()
df = df.assign(group=np.select(condlist, choicelist))
to:
choicelist = list(feature_categories.keys())
df = df.assign(group=np.select(condlist, choicelist, default='other'))
This ensures that both choicelist and default are of the same type (str), resolving the dtype error.
When running the preprocessing pipeline (specifically in
preprocess.py), the following error occurs:This happens at the line:
How to Fix
feature_categories.keys()to a list of strings usinglist().defaultparameter innp.selectto a string value (e.g.,'other'), ensuring all possible outputs are of the same type.Solution
Change this code:
to:
This ensures that both
choicelistanddefaultare of the same type (str), resolving the dtype error.