You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tbenthompson
changed the title
Categorical matrices can't have missings
Error gracefully when on categorical matrices with missing data (segfault is bad).
Mar 18, 2021
Traceback (most recent call last):
File "/home/tbent/Dropbox/active/quantco/quantcore.glm/fail.py", line 24, in <module>
split_matrix = from_pandas(df.astype("category"))
File "/home/tbent/.miniconda3/envs/quantcore.glm/lib/python3.9/site-packages/quantcore/matrix/constructor.py", line 95, in from_pandas
cat = CategoricalMatrix(coldata, dtype=dtype)
File "/home/tbent/.miniconda3/envs/quantcore.glm/lib/python3.9/site-packages/quantcore/matrix/categorical_matrix.py", line 40, in __init__
raise ValueError("Categorical data can't have missing values.")
ValueError: Categorical data can't have missing values.
This produces a segfault:
This works:
I think it's okay not to support this, but this should fail more graciously.
The underlying problem is that
astype(category)
doesn't represent missings as a separate level:The text was updated successfully, but these errors were encountered: