Index objects#

Index#

Many of these methods or variants thereof are available on the objects that contain an index (Series/DataFrame) and those should most likely be used before calling these methods directly.

cudf.Index(data, *args, **kwargs)

Immutable sequence used for indexing and alignment.

Properties#

Index.dtype

dtype of the underlying values in Index.

Index.duplicated([keep])

Indicate duplicate index values.

Index.empty

Index.has_duplicates

Index.hasnans

Return True if there are any NaNs or nulls.

Index.is_monotonic_increasing

Return boolean if values in the object are monotonically increasing.

Index.is_monotonic_decreasing

Return boolean if values in the object are monotonically decreasing.

Index.is_unique

Return boolean if values in the object are unique.

Index.name

Get the name of this object.

Index.names

Returns a FrozenList containing the name of the Index.

Index.ndim

Number of dimensions of the underlying data, by definition 1.

Index.nlevels

Number of levels.

Index.shape

Get a tuple representing the dimensionality of the Index.

Index.size

Return the number of elements in the underlying data.

Index.values

Return a CuPy representation of the DataFrame.

Modifying and computations#

Index.all([axis, skipna])

Return whether all elements are True in DataFrame.

Index.any()

Return whether any elements is True in DataFrame.

Index.copy([name, deep])

Make a copy of this object.

Index.drop_duplicates([keep, nulls_are_equal])

Drop duplicate rows in index.

Index.equals(other)

Test whether two objects contain the same elements.

Index.factorize([sort, use_na_sentinel])

Encode the input values as integer labels.

Index.is_boolean()

Check if the Index only consists of booleans.

Index.is_categorical()

Check if the Index holds categorical data.

Index.is_floating()

Check if the Index is a floating type.

Index.is_integer()

Check if the Index only consists of integers.

Index.is_interval()

Check if the Index holds Interval objects.

Index.is_numeric()

Check if the Index only consists of numeric data.

Index.is_object()

Check if the Index is of the object dtype.

Index.min([axis, skipna, numeric_only])

Return the minimum of the values in the DataFrame.

Index.max([axis, skipna, numeric_only])

Return the maximum of the values in the DataFrame.

Index.rename(name[, inplace])

Alter Index name.

Index.repeat(repeats[, axis])

Repeat elements of a Index.

Index.where(cond[, other, inplace])

Replace values where the condition is False.

Index.take(indices[, axis, allow_fill, ...])

Return a new index containing the rows specified by indices

Index.unique()

Return unique values in the index.

Index.nunique([dropna])

Return count of unique values for the column.

Compatibility with MultiIndex#

Index.set_names(names[, level, inplace])

Set Index or MultiIndex name.

Missing values#

Index.fillna([value, method, axis, inplace, ...])

Fill null values with value or specified method.

Index.dropna([how])

Drop null rows from Index.

Index.isna()

Identify missing values.

Index.isnull()

Identify missing values.

Index.notna()

Identify non-missing values.

Index.notnull()

Identify non-missing values.

Memory usage#

Index.memory_usage([deep])

Return the memory usage of an object.

Conversion#

Index.astype(dtype[, copy])

Create an Index with values cast to dtypes.

Index.deserialize(header, frames)

Generate an object from a serialized representation.

Index.device_deserialize(header, frames)

Perform device-side deserialization tasks.

Index.device_serialize()

Serialize data and metadata associated with device memory.

Index.host_deserialize(header, frames)

Perform device-side deserialization tasks.

Index.host_serialize()

Serialize data and metadata associated with host memory.

Index.serialize()

Generate an equivalent serializable representation of an object.

Index.tolist()

Index.to_arrow()

Convert to a PyArrow Array.

Index.to_cupy([dtype, copy, na_value])

Convert the Frame to a CuPy array.

Index.to_list()

Index.to_numpy([dtype, copy, na_value])

Convert the Frame to a NumPy array.

Index.to_series([index, name])

Create a Series with both index and values equal to the index keys.

Index.to_frame([index, name])

Create a DataFrame with a column containing this Index

Index.to_pandas(*[, nullable, arrow_type])

Convert to a Pandas Index.

Index.to_dlpack()

Converts a cuDF object into a DLPack tensor.

Index.from_pandas(index[, nan_as_null])

Convert from a Pandas Index.

Index.from_arrow(obj)

Create from PyArrow Array/ChunkedArray.

Sorting#

Index.argsort([axis, kind, order, ...])

Return the integer indices that would sort the index.

Index.find_label_range(loc)

Translate a label-based slice to an index-based slice

Index.searchsorted(values[, side, sorter, ...])

Find indices where elements should be inserted to maintain order

Index.sort_values([return_indexer, ...])

Return a sorted copy of the index, and optionally return the indices that sorted the index itself.

Time-specific operations#

Index.shift([periods, freq])

Not yet implemented

Combining / joining / set operations#

Index.append(other)

Append a collection of Index objects together.

Index.union(other[, sort])

Form the union of two Index objects.

Index.intersection(other[, sort])

Form the intersection of two Index objects.

Index.join(other[, how, level, ...])

Compute join_index and indexers to conform data structures to the new index.

Index.difference(other[, sort])

Return a new Index with elements from the index that are not in other.

Selecting#

Index.get_indexer(target[, method, limit, ...])

Compute indexer and mask for new index given the current index.

Index.get_level_values(level)

Return an Index of values for requested level.

Index.get_loc(key)

Get integer location, slice or boolean mask for requested label.

Index.get_slice_bound(label, side)

Calculate slice bound that corresponds to given label.

Index.isin(values)

Return a boolean array where the index values are in values.

String Operations#

Index.str

Vectorized string functions for Series and Index.

Numeric Index#

RangeIndex(start[, stop, step, dtype, copy, ...])

Immutable Index implementing a monotonic integer range.

RangeIndex.start

The value of the start parameter (0 if this was not supplied).

RangeIndex.stop

The value of the stop parameter.

RangeIndex.step

The value of the step parameter.

RangeIndex.to_numpy()

Convert to a numpy array.

RangeIndex.to_arrow()

Convert to a suitable Arrow object.

CategoricalIndex#

CategoricalIndex(data, *args, **kwargs)

A categorical of orderable values that represent the indices of another Column

Categorical components#

CategoricalIndex.codes

The category codes of this categorical.

CategoricalIndex.categories

The categories of this categorical.

Modifying and computations#

CategoricalIndex.equals(other)

Test whether two objects contain the same elements.

IntervalIndex#

IntervalIndex(data, *args, **kwargs)

Immutable index of intervals that are closed on the same side.

IntervalIndex components#

IntervalIndex.from_breaks(breaks[, closed, ...])

Construct an IntervalIndex from an array of splits.

IntervalIndex.values

Return a CuPy representation of the DataFrame.

IntervalIndex.get_indexer(target[, method, ...])

Compute indexer and mask for new index given the current index.

IntervalIndex.get_loc(key)

Get integer location, slice or boolean mask for requested label.

MultiIndex#

MultiIndex([levels, codes, sortorder, ...])

A multi-level or hierarchical index.

MultiIndex constructors#

MultiIndex.from_arrays(arrays[, sortorder, ...])

Convert arrays to MultiIndex.

MultiIndex.from_tuples(tuples[, names])

Convert list of tuples to MultiIndex.

MultiIndex.from_product(arrays[, names])

Make a MultiIndex from the cartesian product of multiple iterables.

MultiIndex.from_frame(df[, names])

Make a MultiIndex from a DataFrame.

MultiIndex.from_arrow(data)

Convert from PyArrow Table to Frame

MultiIndex properties#

MultiIndex.names

Returns a FrozenList containing the name of the Index.

MultiIndex.levels

Returns list of levels in the MultiIndex

MultiIndex.codes

Returns the codes of the underlying MultiIndex.

MultiIndex.nlevels

Integer number of levels in this MultiIndex.

MultiIndex components#

MultiIndex.to_frame([index, name, ...])

Create a DataFrame with the levels of the MultiIndex as columns.

MultiIndex.droplevel([level])

Removes the specified levels from the MultiIndex.

MultiIndex.swaplevel([i, j])

Swap level i with level j.

MultiIndex selecting#

MultiIndex.get_indexer(target[, method, ...])

Compute indexer and mask for new index given the current index.

MultiIndex.get_loc(key)

Get integer location, slice or boolean mask for requested label.

MultiIndex.get_level_values(level)

Return the values at the requested level

DatetimeIndex#

DatetimeIndex(data, *args, **kwargs)

Immutable , ordered and sliceable sequence of datetime64 data, represented internally as int64.

Time/date components#

DatetimeIndex.year

The year of the datetime.

DatetimeIndex.month

The month as January=1, December=12.

DatetimeIndex.day

The day of the datetime.

DatetimeIndex.hour

The hours of the datetime.

DatetimeIndex.minute

The minutes of the datetime.

DatetimeIndex.second

The seconds of the datetime.

DatetimeIndex.microsecond

The microseconds of the datetime.

DatetimeIndex.nanosecond

The nanoseconds of the datetime.

DatetimeIndex.day_of_year

The day of the year, from 1-365 in non-leap years and from 1-366 in leap years.

DatetimeIndex.dayofyear

The day of the year, from 1-365 in non-leap years and from 1-366 in leap years.

DatetimeIndex.dayofweek

The day of the week with Monday=0, Sunday=6.

DatetimeIndex.weekday

The day of the week with Monday=0, Sunday=6.

DatetimeIndex.quarter

Integer indicator for which quarter of the year the date belongs in.

DatetimeIndex.is_leap_year

Boolean indicator if the date belongs to a leap year.

DatetimeIndex.isocalendar()

Returns a DataFrame with the year, week, and day calculated according to the ISO 8601 standard.

Time-specific operations#

DatetimeIndex.round(freq)

Perform round operation on the data to the specified freq.

DatetimeIndex.ceil(freq)

Perform ceil operation on the data to the specified freq.

DatetimeIndex.floor(freq)

Perform floor operation on the data to the specified freq.

DatetimeIndex.tz_convert(tz)

Convert tz-aware datetimes from one time zone to another.

DatetimeIndex.tz_localize(tz[, ambiguous, ...])

Localize timezone-naive data to timezone-aware data.

Conversion#

DatetimeIndex.to_series([index, name])

Create a Series with both index and values equal to the index keys.

DatetimeIndex.to_frame([index, name])

Create a DataFrame with a column containing this Index

TimedeltaIndex#

TimedeltaIndex(data, *args, **kwargs)

Immutable, ordered and sliceable sequence of timedelta64 data, represented internally as int64.

Components#

TimedeltaIndex.days

Number of days for each element.

TimedeltaIndex.seconds

Number of seconds (>= 0 and less than 1 day) for each element.

TimedeltaIndex.microseconds

Number of microseconds (>= 0 and less than 1 second) for each element.

TimedeltaIndex.nanoseconds

Number of nanoseconds (>= 0 and less than 1 microsecond) for each element.

TimedeltaIndex.components

Return a dataframe of the components (days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) of the Timedeltas.

TimedeltaIndex.inferred_freq

Infers frequency of TimedeltaIndex.

Conversion#

TimedeltaIndex.to_series([index, name])

Create a Series with both index and values equal to the index keys.

TimedeltaIndex.to_frame([index, name])

Create a DataFrame with a column containing this Index