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, tupleize_cols])

The basic object storing row labels for all cuDF objects.

Properties

Index.gpu_values

View the data as a numba device array object

Index.names

Returns a tuple containing the name of the Index.

Index.nlevels

Number of levels.

Index.values

Modifying and computations

Index.any()

Return whether any elements is True in Index.

Index.copy([deep])

Index.rename(name[, inplace])

Alter Index name.

Index.take(indices)

Gather only the specific subset of 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.

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

Sorting

Index.argsort([ascending])

Return the integer indices that would sort the index.

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

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

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

Time-specific operations

DatetimeIndex.round([decimals, how])

Round a DataFrame to a variable number of decimal places.

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.round([decimals, how])

Round a DataFrame to a variable number of decimal places.

TimedeltaIndex.to_frame([index, name])

Create a DataFrame with a column containing this Index