Skip to content

series

Series

Series(
    data,
    index=None,
    filters=None,
    order_by_columns=None,
    name="Series",
    saola_connector=None,
)

Bases: ImmutableObject

One dimensional PQL Series.

Parameters:

  • data (ColumnLike) –

    Data to be used. Can be either PQL query string, PQLColumn, or PQLOperator.

  • index (Optional[BaseIndex]) –

    Index to be used. Default is RangeIndex.

  • filters (Optional[FiltersLike]) –

    Filters to be used. Default is none.

  • order_by_columns (Optional[List[OrderByColumn]]) –

    OrderByColumns to be used to sort series. Default is none.

  • name (str) –

    Name of series.

  • saola_connector (Optional[SaolaConnector]) –

    Saola connector used to export data.

data property

data: PQLOperator

Returns data of series.

index property

index: BaseIndex

Returns index of series.

filters property

filters: Filters

Returns filters of series.

order_by_columns property

order_by_columns: List[OrderByColumn]

Returns order by columns of series.

name property

name: str

Returns name of series.

saola_connector property

saola_connector: SaolaConnector

Returns saola connector of series.

query property

query: PQL

Returns PQL query of series.

query_column property

query_column: PQLColumn

Returns PQL column of series.

query_filters property

query_filters: List[PQLFilter]

Returns filters of series.

query_order_by_columns property

query_order_by_columns: List[OrderByColumn]

Returns order by columns of series.

ndim property

ndim: int

Returns an int representing the number of axes.

nrows property

nrows: int

Returns an int representing the number of rows of this series.

size property

size: int

Returns an int representing the number of elements in this series.

shape property

shape: Tuple[int]

Returns a tuple representing the shape of this series.

empty property

empty: bool

Returns whether series is empty.

str property

str: StringMethods

Return string methods object containing all string-specific methods.

dt property

dt: DatetimeMethods

Return datetime methods object containing all datetime-specific methods.

is_unique property

is_unique: bool

Return boolean if values in the object are unique.

hasnans property

hasnans: bool

Return boolean if there are any null values in the object.

head

head(n=5)

Returns the first n rows based on position as pandas Series.

Parameters:

  • n (int) –

    Number of rows to return.

Returns:

  • pd.Series

    First n rows as pandas Series.

to_pandas

to_pandas(distinct=None, limit=None, offset=None)

Exports data of given query using saola connector.

pu

pu(target_table)

Return pull up aggregation methods object containing all pull-up methods.

Parameters:

  • target_table (str) –

    The table to which the aggregation result should be pulled.

Returns:

add

add(other)

Return addition of series and other.

Applies ADD operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

sub

sub(other)

Return subtraction of series and other.

Applies SUB operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

mul

mul(other)

Return multiplication of series and other.

Applies MULT operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

div

div(other)

Return division of series and other.

Applies DIV operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

floordiv

floordiv(other)

Return floor division of series and other.

Applies FLOOR operator and DIV operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

mod

mod(other)

Return modulo of series and other.

Applies MODULO operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

pow

pow(other)

Return the series raised to the power of the other.

Applies POWER operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

abs

abs()

Return the series with the absolute value of its elements.

Applies ABS operator to column.

round

round(decimals=0)

Round series to given number of decimals.

Applies ROUND operator to column.

lt

lt(other)

Return a Series of booleans indicating whether each element is less than the other.

Applies LOWER_THAN operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

le

le(other)

Return a Series of booleans indicating whether each element is less than or equal to the other.

Applies LOWER_EQUALS operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

eq

eq(other)

Return a Series of booleans indicating whether each element is equal to the other.

Applies EQUALS operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

ne

ne(other)

Return a Series of booleans indicating whether each element is not equal to the other.

Applies NOT_EQUALS operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

ge

ge(other)

Return a Series of booleans indicating whether each element is greater than or equal to the other.

Applies GREATER_EQUALS operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

gt

gt(other)

Return a Series of booleans indicating whether each element is greater than the other.

Applies GREATER_THAN operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

isnull

isnull()

Return a boolean same-sized Series indicating if the values are null.

Applies IS NULL operator to column.

Returns:

  • Series

    A Series of masked bool values for each element that indicates whether an element is a null value.

isin

isin(values)

Returns whether elements of series are in values.

Applies IN operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

between

between(left, right)

Return boolean Series equivalent to left <= series <= right.

Applies BETWEEN operator to column.

Parameters:

Returns:

  • Series

    The result of the operation.

mean

mean()

Return the mean of the values.

Applies AVG operator to column.

Returns:

median

median()

Return the median of the values.

Applies MEDIAN operator to column.

Returns:

quantile

quantile(q=0.5)

Return the quantile of the values.

Applies QUANTILE operator to column.

Parameters:

  • q (float) –

    Quantile to compute. 0 <= q <= 1.

Returns:

mode

mode()

Return a series containing a single mode of the values.

Applies MODE operator to column. For multi-modal input, i.e. there are several result candidates, the element with the smallest value is chosen. For elements of type STRING, the smallest value is determined by its lexicographical order

Returns:

  • Series

    Mode of series values.

max

max()

Return the max of the values.

Applies MAX operator to column.

Returns:

min

min()

Return the min of the values.

Applies MIN operator to column.

Returns:

sum

sum()

Return the sum of the values.

Applies SUM operator to column.

Returns:

product

product()

Return the product of the non-null values. Null values are skipped.

Applies PRODUCT operator to column. In case of an overflow the result will be null.

Returns:

count

count()

Return the number of non-null values.

Applies COUNT operator to column.

Returns:

var

var()

Return the variance of the given series using the n-1 method. Null values are ignored.

Applies VAR operator to column.

Returns:

std

std()

Return the standard deviation of the given series using the n-1 method. Null values are ignored.

Applies STDEV operator to column.

Returns:

to_int

to_int()

Converts given series to int.

Applies TO_INT operator to column.

to_float

to_float()

Converts given series to float.

Applies TO_FLOAT operator to column.

to_string

to_string(format_=None)

Converts given series to string.

Applies TO_STRING operator to column.

Parameters:

  • format_ (Optional[str]) –

    Optional, defines how dates are converted to string.

Returns:

  • Series

    Series converted to string.

to_date

to_date(format_)

Converts given series to date.

Applies TO_DATE operator to column.

Parameters:

  • format_ (str) –

    Defines how strings are converted to date.

Returns:

  • Series

    Series converted to date.

astype

astype(type_, **kwargs)

Converts given series to type.

Parameters:

  • type_ (Type[Union[str, int, float]]) –

    Type to convert to. Supported types are str, int, float.

  • **kwargs (Any) –

    Passed to conversion function.

Returns:

  • Series

    Converted series.

dropna

dropna()

Return Series with filter for null values.

Returns:

  • Series

    A Series with null values filtered out.

unique

unique()

Returns all distinct elements of series.

nunique

nunique(dropna=True)

Returns number of unique elements in series.

Parameters:

  • dropna (bool) –

    Whether none values are counted or not.

Returns:

  • int

    Number of unique elements in series.

value_counts

value_counts(
    normalize=False, sort=True, ascending=False, dropna=True
)

Return a Series containing counts of unique values.

Parameters:

  • normalize (bool) –

    If True the relative frequencies of the unique values will be returned.

  • sort (bool) –

    Sort by frequencies.

  • ascending (bool) –

    Sort in ascending order.

  • dropna (bool) –

    Don't include counts of Null.

Returns:

  • Series

    A Series of counts of unique values.

set_filters

set_filters(filters)

Removes filters of series.

reset_filters

reset_filters()

Removes all filters.

reindex

reindex(index)

Updates index of series and drops old index.

reset_index

reset_index()

Resets index to default.

sort_values

sort_values(ascending=True)

Sorts series.

Parameters:

  • ascending (bool) –

    Sort ascending or descending.

Returns:

  • Series

    Series with OrderByColumns set.

apply_unary_operator

apply_unary_operator(operator, **kwargs)

Applies given unary operator to series.

Parameters:

Returns:

  • Series

    Series with operator applied.

apply_binary_operator

apply_binary_operator(
    other, operator, reverse=False, **kwargs
)

Applies given binary operator to series.

Parameters:

  • other (Union[Series, ScalarValue]) –

    Other operand to apply binary operator on.

  • operator (Type[BinaryPQLOperator]) –

    Operator to apply.

  • reverse (bool) –

    If true order of operands is reversed.

Returns:

  • Series

    Series with operator applied.

apply_binary_operator_dunder

apply_binary_operator_dunder(
    other, operator, reverse=False
)

Combines series with the other for dunder methods.

apply_aggregation_operator

apply_aggregation_operator(operator, **kwargs)

Applies given aggregation operator to series and exports result.

Parameters:

Returns:

copy

copy(
    data=None,
    index=None,
    filters=None,
    order_by_columns=None,
    name=None,
    saola_connector=None,
)

Copies given series and overrides properties given as parameters.