Returns whether the categories in `x` are known. Parameters ---------- x : Series or CategoricalIndex
(x)
| 174 | |
| 175 | |
| 176 | def has_known_categories(x): |
| 177 | """Returns whether the categories in `x` are known. |
| 178 | |
| 179 | Parameters |
| 180 | ---------- |
| 181 | x : Series or CategoricalIndex |
| 182 | """ |
| 183 | x = getattr(x, "_meta", x) |
| 184 | if is_series_like(x): |
| 185 | return UNKNOWN_CATEGORIES not in x.cat.categories |
| 186 | elif is_index_like(x) and hasattr(x, "categories"): |
| 187 | return UNKNOWN_CATEGORIES not in x.categories |
| 188 | raise TypeError("Expected Series or CategoricalIndex") |
| 189 | |
| 190 | |
| 191 | def strip_unknown_categories(x, just_drop_unknown=False): |