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

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

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

Return if the index has unique values.

Index.name

Returns the name of the Index.

Index.names

Returns a tuple 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 data.

Index.size

Index.values

Modifying and computations#

Index.any()

Return whether any elements is True in Index.

Index.copy([deep])

Index.drop_duplicates([keep, nulls_are_equal])

Drop duplicate rows in index.

Index.equals(other)

Determine if two Index objects contain the same elements.

Index.factorize([sort, na_sentinel, ...])

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

The minimum value of the index.

Index.max()

The maximum value of the index.

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.

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.

Index.dropna([how])

Drop null rows from Index.

Index.isna()

Detect missing values.

Index.notna()

Detect existing (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 suitable Arrow object.

Index.to_cupy()

Convert to a cupy array.

Index.to_list()

Index.to_numpy()

Convert 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])

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.argsort(*args, **kwargs)

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(value[, side, ascending, ...])

Find index 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_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.

String Operations#

Index.str

Not yet implemented.

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.

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)

Test whether two 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(breaks[, closed, ...])

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_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 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 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_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.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, 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