Series in Arkouda

Like Pandas, Arkouda supports Series. The purpose and intended functionality remains the same in Arkouda, but are configured to be based on arkouda.pdarrays.

class arkouda.Series(data, name=None, index=None)[source]

One-dimensional arkouda array with axis labels.

Parameters:
  • index (pdarray, Strings) – an array of indices associated with the data array. If empty, it will default to a range of ints whose size match the size of the data. optional

  • data (Tuple, List, groupable_element_type, Series, SegArray) – a 1D array. Must not be None.

Raises:
  • TypeError – Raised if index is not a pdarray or Strings object Raised if data is not a pdarray, Strings, or Categorical object

  • ValueError – Raised if the index size does not match data size

Notes

The Series class accepts either positional arguments or keyword arguments. If entering positional arguments,

2 arguments entered:

argument 1 - data argument 2 - index

1 argument entered:

argument 1 - data

If entering 1 positional argument, it is assumed that this is the data argument. If only ‘data’ argument is passed in, Index will automatically be generated. If entering keywords,

‘data’ (see Parameters) ‘index’ (optional) must match size of ‘data’

Features

Series support the majority of functionality offered by pandas.Series.

Lookup

arkouda.Series.locate(self, key)

Lookup values by index label.

Parameters:

key (int, pdarray, Index, Series, List, or Tuple) –

The key or keys to look up. This can be: - A scalar - A list of scalars - A list of lists (for MultiIndex) - A Series (in which case labels are preserved, and its values are used as keys)

Keys will be converted to Arkouda arrays as needed.

Returns:

A Series containing the values corresponding to the key.

Return type:

Series

Lookup

arkouda.Series.locate(self, key)

Lookup values by index label.

Parameters:

key (int, pdarray, Index, Series, List, or Tuple) –

The key or keys to look up. This can be: - A scalar - A list of scalars - A list of lists (for MultiIndex) - A Series (in which case labels are preserved, and its values are used as keys)

Keys will be converted to Arkouda arrays as needed.

Returns:

A Series containing the values corresponding to the key.

Return type:

Series

Sorting

arkouda.Series.sort_index(self, ascending=True)

Sort the Series by its index.

Parameters:

ascending (bool, default=True) – Whether to sort the index in ascending (default) or descending order.

Returns:

A new Series sorted by index.

Return type:

Series

arkouda.Series.sort_values(self, ascending=True)

Sort the Series by its values.

Parameters:

ascending (bool, default=True) – Whether to sort values in ascending (default) or descending order.

Returns:

A new Series sorted by its values.

Return type:

Series

Head/Tail

arkouda.Series.topn(self, n=10)

Return the top values of the Series.

Parameters:

n (int, default=10) – Number of values to return. The default of 10 returns the top 10 values.

Returns:

A new Series containing the top n values.

Return type:

Series

arkouda.Series.head(self, n=10)

Return the first n values of the series

Return type:

Series

arkouda.Series.tail(self, n=10)

Return the last n values of the series

Return type:

Series

Value Counts

arkouda.Series.value_counts(self, sort=True)

Return a Series containing counts of unique values.

Parameters:

sort (bool, default=True) – Whether to sort the result by count in descending order. If False, the order of the results is not guaranteed.

Returns:

A Series where the index contains the unique values and the values are their counts in the original Series.

Return type:

Series

Pandas Integration

arkouda.Series.to_pandas(self)

Convert the series to a local PANDAS series

Return type:

Series

arkouda.Series.pdconcat(arrays, axis=0, labels=None)

Concatenate a list of Arkouda Series or grouped arrays, returning a local pandas object.

If a list of grouped Arkouda arrays is passed, they are converted to Series. Each grouping is a 2-tuple with the first item being the key(s) and the second the value.

If axis=1 (horizontal), each Series or grouping must have the same length and the same index. The index is converted to a column in the resulting DataFrame. If it is a MultiIndex, each level is converted to a separate column.

Parameters:
  • arrays (List) – A list of Series or groupings (tuples of index and values) to concatenate.

  • axis (int, default=0) – The axis along which to concatenate: - 0 = vertical (stack into a Series) - 1 = horizontal (align by index into a DataFrame)

  • labels (Strings or None, optional) – Names to assign to the resulting columns in the DataFrame.

Returns:

  • If axis=0: a local pandas Series

  • If axis=1: a local pandas DataFrame

Return type:

Series or DataFrame