inmoose.utils.Factor
- class inmoose.utils.Factor(arr)
A class to represent a factor, as in R.
It is essentially a
pandas.Categoricalobject, with additional methods to mimic R API.- __init__(arr)
Constructs a Factor instance from an array
- Parameters:
arr (array_like) – a list of factors
Methods
__init__(arr)Constructs a Factor instance from an array
add_categories(new_categories)Add new categories.
argmax([axis, skipna])Return the index of maximum value.
argmin([axis, skipna])Return the index of minimum value.
argsort(*[, ascending, kind])Return the indices that would sort the Categorical.
as_ordered()Set the Categorical to be ordered.
as_unordered()Set the Categorical to be unordered.
astype(dtype[, copy])Coerce this type to another dtype
check_for_ordered(op)assert that we are ordered
copy([order])Return a copy of the array.
delete(loc[, axis])describe()Describes this Categorical
droplevels()drop unused levels
dropna()Return ExtensionArray without NA values.
duplicated([keep])Return boolean ndarray denoting duplicate values.
equals(other)Returns True if categorical arrays are equal.
factorize([use_na_sentinel])Encode the extension array as an enumerated type.
fillna([value, method, limit, copy])Fill NA/NaN values using the specified method.
from_codes(codes[, categories, ordered, ...])Make a Categorical type from codes and categories or dtype.
insert(loc, item)Make new ExtensionArray inserting new item at location.
interpolate(*, method, axis, index, limit, ...)See DataFrame.interpolate.__doc__.
isin(values)Check whether values are contained in Categorical.
isna()Detect missing values
isnull()Detect missing values
map(mapper, na_action)Map categories using an input mapping or function.
max(*[, skipna])The maximum value of the object.
memory_usage([deep])Memory usage of my values
min(*[, skipna])The minimum value of the object.
nlevels()the number of levels
notna()Inverse of isna
notnull()Inverse of isna
ravel([order])Return a flattened view on this array.
remove_categories(removals)Remove the specified categories.
remove_unused_categories()Remove categories which are not used.
rename_categories(new_categories)Rename categories.
reorder_categories(new_categories[, ordered])Reorder categories as specified in new_categories.
repeat(repeats[, axis])Repeat elements of a ExtensionArray.
reshape(*args, **kwargs)searchsorted(value[, side, sorter])Find indices where elements should be inserted to maintain order.
set_categories(new_categories[, ordered, rename])Set the categories to the specified new categories.
set_ordered(value)Set the ordered attribute to the boolean value.
shift([periods, fill_value])Shift values by desired number.
sort_values(*[, inplace, ascending, na_position])Sort the Categorical by category value returning a new Categorical by default.
swapaxes(axis1, axis2)take(indices, *[, allow_fill, fill_value, axis])Take elements from an array.
to_list()Alias for tolist.
to_numpy(dtype, copy, na_value)Convert to a NumPy ndarray.
tolist()Return a list of the values.
transpose(*axes)Return a transposed view on this array.
unique()Return the
Categoricalwhichcategoriesandcodesare unique.value_counts([dropna])Return a Series containing counts of each category.
view([dtype])Return a view on the array.
Attributes
TcategoriesThe categories of this categorical.
codesThe category codes of this categorical index.
dtypeThe
CategoricalDtypefor this instance.nbytesThe number of bytes needed to store this object in memory.
ndimorderedWhether the categories have an ordered relationship.
shapesize