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, dtype, copy, name, ...])

The basic object storing row labels for all cuDF objects.

Properties

Index.gpu_values

View the data as a numba device array object

Index.has_duplicates

Index.is_monotonic

Return boolean if values in the object are monotonic_increasing.

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.names

Returns a tuple containing the name of the Index.

Index.nlevels

Number of levels.

Index.size

Index.values

Modifying and computations

Index.any()

Return whether any elements is True in Index.

Index.copy([deep])

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.rename(name[, inplace])

Alter Index name.

Index.unique()

Return unique values in the index.

Compatibility with MultiIndex

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

Set Index or MultiIndex name.

Missing values

Index.fillna(value[, downcast])

Fill null values with the specified value.

Memory usage

Index.memory_usage([deep])

Memory usage of the values.

Conversion

Index.astype(dtype[, copy])

Create an Index with values cast to dtypes.

Index.to_array([fillna])

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()

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)

Sorting

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

Combining / joining / set operations

Index.append(other)

Append a collection of Index options 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_level_values(level)

Return an Index of values for requested level.

Index.get_loc(key[, method, tolerance])

Index.get_slice_bound(label, side[, kind])

Calculate slice bound that corresponds to given label.

Index.isin(values)

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

Numeric Index

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

Immutable Index implementing a monotonic integer range.

Int64Index([data, dtype, copy, name])

Immutable, ordered and sliceable sequence of labels.

UInt64Index([data, dtype, copy, name])

Immutable, ordered and sliceable sequence of labels.

Float64Index([data, dtype, copy, name])

Immutable, ordered and sliceable sequence of labels.

CategoricalIndex

CategoricalIndex([data, categories, ...])

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, **kwargs)

Determine if two Index objects contain the same elements.

IntervalIndex

IntervalIndex(data[, closed, dtype, copy, name])

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

IntervalIndex components

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

Construct an IntervalIndex from an array of splits.

IntervalIndex.values

Return a CuPy representation of the DataFrame.

IntervalIndex.get_loc(key[, method, tolerance])

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_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 tuple 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 a column containing this Index

MultiIndex.droplevel([level])

Removes the specified levels from the MultiIndex.

MultiIndex selecting

MultiIndex.get_loc(key[, method, tolerance])

Get location for a label or a tuple of labels.

MultiIndex.get_level_values(level)

Return the values at the requested level

DatetimeIndex

DatetimeIndex([data, freq, tz, normalize, ...])

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.dayofweek

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

DatetimeIndex.dayofyear

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

DatetimeIndex.day_of_year

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

DatetimeIndex.weekday

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

DatetimeIndex.is_leap_year

Boolean indicator if the date belongs to a leap year.

DatetimeIndex.quarter

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

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.

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, unit, freq, closed, ...])

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