Allow NaN Intervals and to allow NaN as a Groupby Category #28927
Labels
Categorical
Categorical Data Type
Closing Candidate
May be closeable, needs more eyeballs
Enhancement
Groupby
Interval
Interval data type
Code Sample
Problem description
Warning: This is something of an XYZ problem.
Ultimately, I want to be able to groupby Intervals AND include NaNs as one of the groups. Ideally, this would be displayed as NaNs but groupby doesn't include categorical NaNs. It would be acceptable to display this with -99, for example.
However, if I had only the NaN value as seen before the cut, I could easily pre-fill (
fillna
) with -99 but here the cut generates the NaN associated with the 10 value.Now I try to fillna on the IntervalIndex code-comment # - 2 but it doesn't let me do a categorical fillna for things not in the Category.
ValueError: fill value must be in categories
To try and solve this, I tried adding a "NaN Interval" as shown in code comment # - 1. This throws
ValueError: left side of interval must be <= right side
.Expected Output
Ultimately,
But it seems there are a few issues to tackle along the way.
Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here below this line]The text was updated successfully, but these errors were encountered: