Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Module « pandas »

Classe « CategoricalIndex »

Informations générales

Héritage

                builtins.object
                    PandasDelegate
builtins.object
    DirNamesMixin
        PandasObject
builtins.object
    OpsMixin
        IndexOpsMixin
            Index
                ExtensionIndex
                    NDArrayBackedExtensionIndex
                        CategoricalIndex

Définition

class CategoricalIndex(NDArrayBackedExtensionIndex, PandasDelegate):

Description [extrait de CategoricalIndex.__doc__]

    Index based on an underlying :class:`Categorical`.

    CategoricalIndex, like Categorical, can only take on a limited,
    and usually fixed, number of possible values (`categories`). Also,
    like Categorical, it might have an order, but numerical operations
    (additions, divisions, ...) are not possible.

    Parameters
    ----------
    data : array-like (1-dimensional)
        The values of the categorical. If `categories` are given, values not in
        `categories` will be replaced with NaN.
    categories : index-like, optional
        The categories for the categorical. Items need to be unique.
        If the categories are not given here (and also not in `dtype`), they
        will be inferred from the `data`.
    ordered : bool, optional
        Whether or not this categorical is treated as an ordered
        categorical. If not given here or in `dtype`, the resulting
        categorical will be unordered.
    dtype : CategoricalDtype or "category", optional
        If :class:`CategoricalDtype`, cannot be used together with
        `categories` or `ordered`.
    copy : bool, default False
        Make a copy of input ndarray.
    name : object, optional
        Name to be stored in the index.

    Attributes
    ----------
    codes
    categories
    ordered

    Methods
    -------
    rename_categories
    reorder_categories
    add_categories
    remove_categories
    remove_unused_categories
    set_categories
    as_ordered
    as_unordered
    map

    Raises
    ------
    ValueError
        If the categories do not validate.
    TypeError
        If an explicit ``ordered=True`` is given but no `categories` and the
        `values` are not sortable.

    See Also
    --------
    Index : The base pandas Index type.
    Categorical : A categorical array.
    CategoricalDtype : Type for categorical data.

    Notes
    -----
    See the `user guide
    <https://pandas.pydata.org/pandas-docs/stable/user_guide/advanced.html#categoricalindex>`_
    for more.

    Examples
    --------
    >>> pd.CategoricalIndex(["a", "b", "c", "a", "b", "c"])
    CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c'],
                     categories=['a', 'b', 'c'], ordered=False, dtype='category')

    ``CategoricalIndex`` can also be instantiated from a ``Categorical``:

    >>> c = pd.Categorical(["a", "b", "c", "a", "b", "c"])
    >>> pd.CategoricalIndex(c)
    CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c'],
                     categories=['a', 'b', 'c'], ordered=False, dtype='category')

    Ordered ``CategoricalIndex`` can have a min and max value.

    >>> ci = pd.CategoricalIndex(
    ...     ["a", "b", "c", "a", "b", "c"], ordered=True, categories=["c", "b", "a"]
    ... )
    >>> ci
    CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c'],
                     categories=['c', 'b', 'a'], ordered=True, dtype='category')
    >>> ci.min()
    'c'
    

Constructeur(s)

Signature du constructeur Description
__new__(cls, data=None, categories=None, ordered=None, dtype=None, copy=False, name=None)

Liste des attributs statiques

Nom de l'attribut Valeur
array<pandas._libs.properties.CachedProperty object at 0x7f504b9fe2c0>
dtype<pandas._libs.properties.CachedProperty object at 0x7f504bd2af00>
hasnans<pandas._libs.properties.CachedProperty object at 0x7f504bd34d40>
is_all_dates<pandas._libs.properties.CachedProperty object at 0x7f504bd34c40>
is_unique<pandas._libs.properties.CachedProperty object at 0x7f504bd34880>

Attributs statiques hérités de la classe NDArrayBackedExtensionIndex

inferred_type

Liste des propriétés

Nom de la propriétéDescription
asi8
categories
codes
empty
has_duplicates
inferred_type
is_monotonic
is_monotonic_decreasing
is_monotonic_increasing
name
names
nbytes
ndim
nlevels
ordered
shape
size
T
valuesreturn the underlying data, which is a Categorical [extrait de __doc__]

Propriétés héritées de la classe IndexOpsMixin

array, dtype, is_unique

Liste des opérateurs

Signature de l'opérateur Description
__contains__(self, key: Any) -> bool

Opérateurs hérités de la classe ExtensionIndex

__getitem__

Opérateurs hérités de la classe Index

__and__, __iadd__, __inv__, __neg__, __or__, __pos__, __setitem__, __xor__

Opérateurs hérités de la classe OpsMixin

__add__, __eq__, __floordiv__, __ge__, __gt__, __le__, __lt__, __mod__, __mul__, __ne__, __pow__, __radd__, __rand__, __rfloordiv__, __rmod__, __rmul__, __ror__, __rpow__, __rsub__, __rtruediv__, __rxor__, __sub__, __truediv__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
astype(self, dtype, copy=True)
equals(self, other: object) -> bool
fillna(self, value, downcast=None)
get_indexer(self, target, method=None, limit=None, tolerance=None)
get_indexer_non_unique(self, target)
map(self, mapper)
reindex(self, target, method=None, level=None, limit=None, tolerance=None)
take_nd(self, *args, **kwargs) Alias for `take` [extrait de take_nd.__doc__]
unique(self, level=None)

Méthodes héritées de la classe PandasDelegate

__init_subclass__, __subclasshook__

Méthodes héritées de la classe NDArrayBackedExtensionIndex

delete, insert, putmask, where

Méthodes héritées de la classe ExtensionIndex

repeat, searchsorted

Méthodes héritées de la classe Index

__abs__, __array__, __array_wrap__, __bool__, __copy__, __deepcopy__, __hash__, __len__, __nonzero__, __reduce__, __repr__, all, any, append, argsort, asof, asof_locs, copy, difference, drop, drop_duplicates, droplevel, dropna, duplicated, format, get_indexer_for, get_level_values, get_loc, get_slice_bound, get_value, groupby, holds_integer, identical, intersection, is_, is_boolean, is_categorical, is_floating, is_integer, is_interval, is_mixed, is_numeric, is_object, is_type_compatible, isin, isna, isnull, join, memory_usage, notna, notnull, ravel, rename, set_names, set_value, shift, slice_indexer, slice_locs, sort, sort_values, sortlevel, symmetric_difference, take, to_flat_index, to_frame, to_native_types, to_series, union, view

Méthodes héritées de la classe PandasObject

__sizeof__

Méthodes héritées de la classe DirNamesMixin

__dir__

Méthodes héritées de la classe IndexOpsMixin

__iter__, argmax, argmin, factorize, item, max, min, nunique, to_list, to_numpy, tolist, transpose, value_counts

Méthodes héritées de la classe OpsMixin

__divmod__, __rdivmod__

Méthodes héritées de la classe object

__delattr__, __format__, __getattribute__, __reduce_ex__, __setattr__, __str__