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

The input can be a scalar, a list of scalers, or a list of lists (if the series has a MultiIndex). As a special case, if a Series is used as the key, the series labels are preserved with its values use as the key.

Keys will be turned into arkouda arrays as needed.

Return type:

A Series containing the values corresponding to the key.

Lookup

arkouda.Series.locate(self, key)

Lookup values by index label

The input can be a scalar, a list of scalers, or a list of lists (if the series has a MultiIndex). As a special case, if a Series is used as the key, the series labels are preserved with its values use as the key.

Keys will be turned into arkouda arrays as needed.

Return type:

A Series containing the values corresponding to the key.

Sorting

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

Sort the series by its index

Parameters:

ascending (bool) – Sort values in ascending (default) or descending order.

Return type:

A new Series sorted.

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

Sort the series numerically

Parameters:

ascending (bool) – Sort values in ascending (default) or descending order.

Return type:

A new Series sorted smallest to largest

Head/Tail

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

Return the top values of the series

Parameters:

n (Number of values to return)

Return type:

A new Series with the top values

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.

The resulting object will be in descending order so that the first element is the most frequently-occurring element.

Parameters:

sort (Boolean. Whether or not to sort the results. Default is true.)

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 arkouda arrays, returning a PANDAS object.

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

If horizontal, each series or grouping must have the same length and the same index. The index of the series is converted to a column in the dataframe. If it is a multi-index,each level is converted to a column.

Parameters:
  • arrays (The list of series/groupings to concat.)

  • axis (Whether or not to do a verticle (axis=0) or horizontal (axis=1) concatenation)

  • labels (names to give the columns of the data frame.)

Return type:

Union[Series, DataFrame]

Returns:

  • axis=0 (a local PANDAS series)

  • axis=1 (a local PANDAS dataframe)