MCPcopy Create free account
hub / github.com/dask/dask / has_known_categories

Function has_known_categories

dask/dataframe/utils.py:176–188  ·  view source on GitHub ↗

Returns whether the categories in `x` are known. Parameters ---------- x : Series or CategoricalIndex

(x)

Source from the content-addressed store, hash-verified

174
175
176def 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
191def strip_unknown_categories(x, just_drop_unknown=False):

Callers 11

_repr_data_seriesFunction · 0.90
get_dummiesFunction · 0.90
categorizeMethod · 0.90
pivot_tableFunction · 0.90
knownMethod · 0.90
test_categorical_dtypesFunction · 0.90
check_and_returnFunction · 0.90
test_concat_categoricalFunction · 0.90
strip_unknown_categoriesFunction · 0.85

Calls 2

is_series_likeFunction · 0.90
is_index_likeFunction · 0.90