Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
BUG: method .nunique on categorical series in v0.21 with only NaNs gives ValueError #18051
Code Sample, a copy-pastable example if possible
>>> ser = pd.Series(pd.Categorical([np.nan])) >>> ser.nunique() ValueError: buffer source array is read-only
The above code gave 0 in v20.3 and is expected to give 0 also in v0.21. The problem is independent of if I set some categories.
EDIT: Actually this doesn't give error if I set categories. so this only happens if no categories are set. The use case for no categories in my case is programmatically reading in data, where some columns are empty and of dtype categorical.
This individual issue can be fixed with a simple
If this is something in cython or requires larger refactoring, this will be beyond my ability, I'm sorry.