Indexs in Arkouda¶
Like Pandas, Arkouda supports Indexes
. The purpose and intended functionality remains the same in Arkouda, but are configured to be based on arkouda.pdarrays
.
- class arkouda.Index(values, name=None, allow_list=False, max_list_size=1000)[source]¶
Sequence used for indexing and alignment.
The basic object storing axis labels for all DataFrame objects.
- Parameters:
values (List, pdarray, Strings, Categorical, pandas.Categorical, pandas.Index, or Index)
name (str, default=None) – Name to be stored in the index.
False (allow_list =) – If False, list values will be converted to a pdarray. If True, list values will remain as a list, provided the data length is less than max_list_size.
- :paramIf False, list values will be converted to a pdarray.
If True, list values will remain as a list, provided the data length is less than max_list_size.
- Parameters:
1000 (max_list_size =) – This is the maximum allowed data length for the values to be stored as a list object.
- Raises:
ValueError – Raised if allow_list=True and the size of values is > max_list_size.
See also
Examples
>>> import arkouda as ak >>> ak.Index([1, 2, 3]) Index(array([1 2 3]), dtype='int64')
>>> ak.Index(list('abc')) Index(array(['a', 'b', 'c']), dtype='<U0')
>>> ak.Index([1, 2, 3], allow_list=True) Index([1, 2, 3], dtype='int64')
Additionally, Multi-Indexes
are supported for indexes with multiple keys.
..autoclass:: arkouda.MultiIndex
Features¶
Index
support the majority of functionality offered by pandas.Index
.
Change Dtype¶
- arkouda.Index.set_dtype(self, dtype)¶
Change the data type of the index.
Currently only aku.ip_address and ak.array are supported.
- arkouda.MultiIndex.set_dtype(self, dtype)¶
Change the data type of the index.
Currently only aku.ip_address and ak.array are supported.
ArgSort¶
Lookup¶
- arkouda.Index.lookup(self, key)¶
Check for presence of key(s) in the Index.
- Parameters:
key (pdarray or scalar) – The value(s) to look up in the Index. If a scalar is provided, it will be converted to a one-element array.
- Returns:
A boolean array indicating which elements of key are present in the Index.
- Return type:
- Raises:
TypeError – If key is not a scalar or a pdarray.
- arkouda.MultiIndex.lookup(self, key)¶
Perform element-wise lookup on the MultiIndex.
- Parameters:
key (list or tuple) – A sequence of values, one for each level of the MultiIndex. Values may be scalars or pdarrays. If scalars, they are cast to the appropriate Arkouda array type.
- Returns:
A boolean array indicating which rows in the MultiIndex match the key.
- Return type:
- Raises:
TypeError – If key is not a list or tuple, or if its elements cannot be converted to pdarrays.
Concat¶
- arkouda.Index.concat(self, other)¶
Concatenate this Index with another Index.
- arkouda.MultiIndex.concat(self, other)¶
Concatenate this MultiIndex with another, preserving duplicates and order.
- Parameters:
other (MultiIndex) – The other MultiIndex to concatenate with.
- Returns:
A new MultiIndex containing values from both inputs, preserving order.
- Return type:
- Raises:
TypeError – If the type of other does not match.