cudf.Index#
- class cudf.Index(data=None, dtype=None, copy=False, name=None, tupleize_cols=True, nan_as_null=True, **kwargs)#
The basic object storing row labels for all cuDF objects.
- Parameters:
- dataarray-like (1-dimensional)/ DataFrame
If it is a DataFrame, it will return a MultiIndex
- dtypeNumPy dtype (default: object)
If dtype is None, we find the dtype that best fits the data.
- copybool
Make a copy of input data.
- nameobject
Name to be stored in the index.
- tupleize_colsbool (default: True)
When True, attempt to create a MultiIndex if possible. tupleize_cols == False is not yet supported.
- nan_as_nullbool, Default True
If
None
/True
, convertsnp.nan
values tonull
values. IfFalse
, leavesnp.nan
values as is.
- Returns:
- Index
cudf Index
Warning
This class should not be subclassed. It is designed as a factory for different subclasses of BaseIndex depending on the provided input. If you absolutely must, and if you’re intimately familiar with the internals of cuDF, subclass BaseIndex instead.
Examples
>>> import cudf >>> cudf.Index([1, 2, 3], dtype="uint64", name="a") UInt64Index([1, 2, 3], dtype='uint64', name='a')
>>> cudf.Index(cudf.DataFrame({"a":[1, 2], "b":[2, 3]})) MultiIndex([(1, 2), (2, 3)], names=['a', 'b'])
Attributes
Return True if there are any NaNs or nulls.
Return boolean if values in the object are monotonic_increasing.
Return if the index has unique values.
Returns the name of the Index.
Returns a tuple containing the name of the Index.
Number of dimensions of the underlying data, by definition 1.
Number of levels.
Get a tuple representing the dimensionality of the data.
Not yet implemented.
dtype
empty
has_duplicates
is_monotonic_decreasing
is_monotonic_increasing
size
values
Methods
any
()Return whether any elements is True in Index.
append
(other)Append a collection of Index objects together.
argsort
(*args, **kwargs)Return the integer indices that would sort the index.
astype
(dtype[, copy])Create an Index with values cast to dtypes.
deserialize
(header, frames)Generate an object from a serialized representation.
device_deserialize
(header, frames)Perform device-side deserialization tasks.
Serialize data and metadata associated with device memory.
difference
(other[, sort])Return a new Index with elements from the index that are not in other.
drop_duplicates
([keep, nulls_are_equal])Drop duplicate rows in index.
dropna
([how])Drop null rows from Index.
duplicated
([keep])Indicate duplicate index values.
equals
(other)Determine if two Index objects contain the same elements.
fillna
(value[, downcast])Fill null values with the specified value.
find_label_range
(loc)Translate a label-based slice to an index-based slice
from_pandas
(index[, nan_as_null])Convert from a Pandas Index.
get_level_values
(level)Return an Index of values for requested level.
get_slice_bound
(label, side[, kind])Calculate slice bound that corresponds to given label.
host_deserialize
(header, frames)Perform device-side deserialization tasks.
Serialize data and metadata associated with host memory.
intersection
(other[, sort])Form the intersection of two Index objects.
Check if the Index only consists of booleans.
Check if the Index holds categorical data.
Check if the Index is a floating type.
Check if the Index only consists of integers.
Check if the Index holds Interval objects.
Check if the Index only consists of numeric data.
Check if the Index is of the object dtype.
isin
(values)Return a boolean array where the index values are in values.
isna
()Detect missing values.
join
(other[, how, level, return_indexers, sort])Compute join_index and indexers to conform data structures to the new index.
max
()The maximum value of the index.
memory_usage
([deep])Return the memory usage of an object.
min
()The minimum value of the index.
notna
()Detect existing (non-missing) values.
rename
(name[, inplace])Alter Index name.
repeat
(repeats[, axis])Repeat elements of a Index.
searchsorted
(value[, side, ascending, ...])Find index where elements should be inserted to maintain order
Generate an equivalent serializable representation of an object.
set_names
(names[, level, inplace])Set Index or MultiIndex name.
shift
([periods, freq])Not yet implemented
sort_values
([return_indexer, ascending, ...])Return a sorted copy of the index, and optionally return the indices that sorted the index itself.
take
(indices[, axis, allow_fill, fill_value])Return a new index containing the rows specified by indices
to_arrow
()Convert to a suitable Arrow object.
to_cupy
()Convert to a cupy array.
Converts a cuDF object into a DLPack tensor.
to_frame
([index, name])Create a DataFrame with a column containing this Index
to_numpy
()Convert to a numpy array.
to_pandas
([nullable])Convert to a Pandas Index.
to_series
([index, name])Create a Series with both index and values equal to the index keys.
union
(other[, sort])Form the union of two Index objects.
unique
()Return unique values in the index.
where
(cond[, other, inplace])Replace values where the condition is False.
copy
factorize
from_arrow
get_loc
to_list
tolist