Series

Constructor

Series([name, values, dtype, strict, ...])

A Series represents a single column in a polars DataFrame.

Attributes

Series.arr

Create an object namespace of all list related methods.

Series.cat

Create an object namespace of all categorical related methods.

Series.dt

Create an object namespace of all datetime related methods.

Series.dtype

Get the data type of this Series.

Series.inner_dtype

Get the inner dtype in of a List typed Series

Series.name

Get the name of this Series.

Series.shape

Shape of this Series.

Series.str

Create an object namespace of all string related methods.

Series.time_unit

Get the time unit of underlying Datetime Series as {"ns", "us", "ms"}

Conversion

Series.to_arrow()

Get the underlying Arrow Array.

Series.to_frame()

Cast this Series to a DataFrame.

Series.to_list([use_pyarrow])

Convert this Series to a Python List.

Series.to_numpy(*args[, zero_copy_only])

Convert this Series to numpy.

Series.to_pandas()

Convert this Series to a pandas Series

Aggregation

Series.arg_max()

Get the index of the maximal value.

Series.arg_min()

Get the index of the minimal value.

Series.max()

Get the maximum value in this Series.

Series.mean()

Reduce this Series to the mean value.

Series.median()

Get the median of this Series.

Series.min()

Get the minimal value in this Series.

Series.mode()

Compute the most occurring value(s).

Series.product()

Reduce this Series to the product value.

Series.quantile(quantile[, interpolation])

Get the quantile value of this Series.

Series.std([ddof])

Get the standard deviation of this Series.

Series.sum()

Reduce this Series to the sum value.

Series.var([ddof])

Get variance of this Series.

Descriptive stats

Series.chunk_lengths()

Get the length of each individual chunk.

Series.describe()

Quick summary statistics of a series.

Series.estimated_size()

Returns an estimation of the total (heap) allocated size of the Series in bytes.

Series.has_validity()

Returns True if the Series has a validity bitmask.

Series.is_boolean()

Check if this Series is a Boolean.

Series.is_datelike()

Check if this Series datatype is datelike.

Series.is_duplicated()

Get mask of all duplicated values.

Series.is_empty()

Check if the Series is empty.

Series.is_finite()

Get mask of finite values if Series dtype is Float.

Series.is_first()

Get a mask of the first unique value.

Series.is_float()

Check if this Series has floating point numbers.

Series.is_in(other)

Check if elements of this Series are in the right Series, or List values of the right Series.

Series.is_infinite()

Get mask of infinite values if Series dtype is Float.

Series.is_nan()

Get mask of NaN values if Series dtype is Float.

Series.is_not_nan()

Get negated mask of NaN values if Series dtype is_not Float.

Series.is_not_null()

Get mask of non null values.

Series.is_null()

Get mask of null values.

Series.is_numeric()

Check if this Series datatype is numeric.

Series.is_unique()

Get mask of all unique values.

Series.is_utf8()

Checks if this Series datatype is a Utf8.

Series.len()

Length of this Series.

Series.n_chunks()

Get the number of chunks that this Series contains.

Series.n_unique()

Count the number of unique values in this Series.

Series.null_count()

Count the null values in this Series.

Series.unique_counts()

Returns a count of the unique values in the order of appearance.

Series.value_counts()

Count the unique values in a Series.

Boolean

Series.all()

Check if all boolean values in the column are True

Series.any()

Check if any boolean value in the column is True

Computations

Series.abs()

Take absolute values

Series.arccos()

Compute the element-wise value for Trigonometric Inverse cosine.

Series.arcsin()

Compute the element-wise value for Trigonometric Inverse sine.

Series.arctan()

Compute the element-wise value for Trigonometric Inverse tangent.

Series.arg_true()

Get index values where Boolean Series evaluate True.

Series.arg_unique()

Get unique index as Series.

Series.cos()

Compute the element-wise value for Trigonometric cosine.

Series.cummax([reverse])

Get an array with the cumulative max computed at every element.

Series.cummin([reverse])

Get an array with the cumulative min computed at every element.

Series.cumprod([reverse])

Get an array with the cumulative product computed at every element.

Series.cumsum([reverse])

Get an array with the cumulative sum computed at every element.

Series.cumulative_eval(expr[, min_periods, ...])

Run an expression over a sliding window that increases 1 slot every iteration.

Series.diff([n, null_behavior])

Calculate the n-th discrete difference.

Series.dot(other)

Compute the dot/inner product between two Series

Series.entropy([base, normalize])

Compute the entropy as -sum(pk * log(pk).

Series.ewm_mean([com, span, half_life, ...])

Exponential moving average.

Series.ewm_std([com, span, half_life, ...])

Exponential moving standard deviation.

Series.ewm_var([com, span, half_life, ...])

Exponential moving standard variation.

Series.exp()

Return the exponential element-wise

Series.hash([k0, k1, k2, k3])

Hash the Series.

Series.kurtosis([fisher, bias])

Compute the kurtosis (Fisher or Pearson) of a dataset.

Series.log([base])

Compute the logarithm to a given base

Series.log10()

Return the base 10 logarithm of the input array, element-wise.

Series.pct_change([n])

Percentage change (as fraction) between current element and most-recent non-null element at least n period(s) before the current element.

Series.peak_max()

Get a boolean mask of the local maximum peaks.

Series.peak_min()

Get a boolean mask of the local minimum peaks.

Series.rank([method, reverse])

Assign ranks to data, dealing with ties appropriately.

Series.rolling_apply(function, window_size)

Allows a custom rolling window function.

Series.rolling_max(window_size[, weights, ...])

Apply a rolling max (moving max) over the values in this array.

Series.rolling_mean(window_size[, weights, ...])

Apply a rolling mean (moving mean) over the values in this array.

Series.rolling_median(window_size[, ...])

Compute a rolling median

Series.rolling_min(window_size[, weights, ...])

apply a rolling min (moving min) over the values in this array.

Series.rolling_quantile(quantile[, ...])

Compute a rolling quantile

Series.rolling_skew(window_size[, bias])

Compute a rolling skew

Series.rolling_std(window_size[, weights, ...])

Compute a rolling std dev

Series.rolling_sum(window_size[, weights, ...])

Apply a rolling sum (moving sum) over the values in this array.

Series.rolling_var(window_size[, weights, ...])

Compute a rolling variance.

Series.sign()

Returns an element-wise indication of the sign of a number.

Series.sin()

Compute the element-wise value for Trigonometric sine.

Series.skew([bias])

Compute the sample skewness of a data set.

Series.sqrt()

Compute the square root of the elements

Series.tan()

Compute the element-wise value for Trigonometric tangent.

Series.unique([maintain_order])

Get unique elements in series.

Manipulation/ selection

Series.alias(name)

Rename the Series

Series.append(other[, append_chunks])

Append a Series to this one.

Series.argsort([reverse, nulls_last])

Index location of the sorted variant of this Series.

Series.cast(dtype[, strict])

Cast between data types.

Series.ceil()

Ceil underlying floating point array to the highest integers smaller or equal to the float value.

Series.clip(min_val, max_val)

Clip (limit) the values in an array to any value that fits in 64 floating point range.

Series.clone()

Cheap deep clones.

Series.drop_nans()

Series.drop_nulls()

Create a new Series that copies data from this Series without null values.

Series.explode()

Explode a list or utf8 Series.

Series.extend_constant(value, n)

Extend the Series with given number of values.

Series.fill_nan(fill_value)

Fill floating point NaN value with a fill value

Series.fill_null(strategy[, limit])

Fill null values using a filling strategy, literal, or Expr.

Series.filter(predicate)

Filter elements by a boolean mask.

Series.floor()

Floor underlying floating point array to the lowest integers smaller or equal to the float value.

Series.head([length])

Get first N elements as Series.

Series.interpolate()

Interpolate intermediate values.

Series.limit([num_elements])

Take n elements from this Series.

Series.rechunk()

Create a single chunk of memory for this Series.

Series.rename()

Rename this Series.

Series.reshape(dims)

Reshape this Series to a flat series, shape: (len,) or a List series, shape: (rows, cols)

Series.reverse()

Return Series in reverse order.

Series.round(decimals)

Round underlying floating point data by decimals digits.

Series.sample([n, frac, with_replacement, ...])

Sample from this Series by setting either n or frac.

Series.set(filter, value)

Set masked values.

Series.set_at_idx(idx, value)

Set values at the index locations.

Series.shift([periods])

Shift the values by a given period and fill the parts that will be empty due to this operation with Nones.

Series.shift_and_fill(periods, fill_value)

Shift the values by a given period and fill the parts that will be empty due to this operation with the result of the fill_value expression.

Series.shrink_to_fit()

Shrink memory usage of this Series to fit the exact capacity needed to hold the data.

Series.shuffle([seed])

Shuffle the contents of this Series.

Series.slice(offset[, length])

Get a slice of this Series.

Series.sort()

Sort this Series.

Series.tail([length])

Get last N elements as Series.

Series.take(indices)

Take values by index.

Series.take_every(n)

Take every nth value in the Series and return as new Series.

Series.to_dummies()

Get dummy variables.

Series.view([ignore_nulls])

Get a view into this Series data with a numpy array.

Series.zip_with(mask, other)

Where mask evaluates true, take values from self.

Various

Series.apply(func[, return_dtype])

Apply a function over elements in this Series and return a new Series.

Series.dt

Create an object namespace of all datetime related methods.

Series.reinterpret([signed])

Reinterpret the underlying bits as a signed/unsigned integer.

Series.series_equal(other[, null_equal, strict])

Check if series is equal with another Series.

Series.set_sorted([reverse])

Set this Series as sorted so that downstream code can use fast paths for sorted arrays.

Series.str

Create an object namespace of all string related methods.

Series.to_physical()

Cast to physical representation of the logical dtype.

TimeSeries

The following methods are available under the Series.dt attribute.

DateTimeNameSpace.and_time_unit(tu)

Set time unit a Series of type Datetime

DateTimeNameSpace.and_time_zone(tz)

Set time zone a Series of type Datetime.

DateTimeNameSpace.cast_time_unit(tu)

Cast the underlying data to another time unit.

DateTimeNameSpace.day()

Extract the day from the underlying date representation.

DateTimeNameSpace.days()

Extract the days from a Duration type.

DateTimeNameSpace.epoch([tu])

Get the time passed since the Unix EPOCH in the give time unit

DateTimeNameSpace.epoch_days()

Get the number of days since the unix EPOCH.

DateTimeNameSpace.epoch_milliseconds()

Get the number of milliseconds since the unix EPOCH If the date is before the unix EPOCH, the number of milliseconds will be negative.

DateTimeNameSpace.epoch_seconds()

Get the number of seconds since the unix EPOCH If the date is before the unix EPOCH, the number of seconds will be negative.

DateTimeNameSpace.hour()

Extract the hour from the underlying DateTime representation.

DateTimeNameSpace.hours()

Extract the hours from a Duration type.

DateTimeNameSpace.max()

Return maximum as python DateTime

DateTimeNameSpace.mean()

Return mean as python DateTime

DateTimeNameSpace.median()

Return median as python DateTime

DateTimeNameSpace.milliseconds()

Extract the milliseconds from a Duration type.

DateTimeNameSpace.min()

Return minimum as python DateTime

DateTimeNameSpace.minute()

Extract the minutes from the underlying DateTime representation.

DateTimeNameSpace.minutes()

Extract the minutes from a Duration type.

DateTimeNameSpace.month()

Extract the month from the underlying date representation.

DateTimeNameSpace.nanosecond()

Extract the nanoseconds from the underlying DateTime representation.

DateTimeNameSpace.nanoseconds()

Extract the nanoseconds from a Duration type.

DateTimeNameSpace.ordinal_day()

Extract ordinal day from underlying date representation.

DateTimeNameSpace.offset_by(by)

Offset this date by a relative time offset.

DateTimeNameSpace.quarter()

Extract quarter from underlying Date representation.

DateTimeNameSpace.second()

Extract the seconds the from underlying DateTime representation.

DateTimeNameSpace.seconds()

Extract the seconds from a Duration type.

DateTimeNameSpace.strftime(fmt)

Format Date/datetime with a formatting rule: See chrono strftime/strptime.

DateTimeNameSpace.timestamp([tu])

Return a timestamp in the given time unit.

DateTimeNameSpace.to_python_datetime()

Go from Date/Datetime to python DateTime objects

DateTimeNameSpace.truncate(every[, offset])

DateTimeNameSpace.week()

Extract the week from the underlying date representation.

DateTimeNameSpace.weekday()

Extract the week day from the underlying date representation.

DateTimeNameSpace.with_time_unit(tu)

Set time unit a Series of dtype Datetime or Duration.

DateTimeNameSpace.year()

Extract the year from the underlying date representation.

Strings

The following methods are available under the Series.str attribute.

StringNameSpace.concat([delimiter])

Vertically concat the values in the Series to a single string value.

StringNameSpace.contains(pattern[, literal])

Check if strings in Series contain a substring that matches a regex.

StringNameSpace.count_match(pattern)

Count all successive non-overlapping regex matches.

StringNameSpace.decode(encoding[, strict])

Decodes a value using the provided encoding.

StringNameSpace.encode(encoding)

Encodes a value using the provided encoding

StringNameSpace.ends_with(sub)

Check if string values end with a substring

StringNameSpace.extract(pattern[, group_index])

Extract the target capture group from provided patterns.

StringNameSpace.extract_all(pattern)

Extract each successive non-overlapping regex match in an individual string as an array

StringNameSpace.json_path_match(json_path)

Extract the first match of json string with provided JSONPath expression.

StringNameSpace.lengths()

Get length of the string values in the Series.

StringNameSpace.ljust(width[, fillchar])

Return the string left justified in a string of length width.

StringNameSpace.lstrip()

Remove leading whitespace.

StringNameSpace.replace(pattern, value)

Replace first regex match with a string value.

StringNameSpace.replace_all(pattern, value)

Replace all regex matches with a string value.

StringNameSpace.rjust(width[, fillchar])

Return the string right justified in a string of length width.

StringNameSpace.rstrip()

Remove trailing whitespace.

StringNameSpace.slice(start[, length])

Create subslices of the string values of a Utf8 Series.

StringNameSpace.split(by[, inclusive])

Split the string by a substring.

StringNameSpace.split_exact(by, n[, inclusive])

Split the string by a substring into a struct of n fields.

StringNameSpace.starts_with(sub)

Check if string values start with a substring

StringNameSpace.strip()

Remove leading and trailing whitespace.

StringNameSpace.strptime(datatype[, fmt, ...])

Parse a Series of dtype Utf8 to a Date/Datetime Series.

StringNameSpace.to_lowercase()

Modify the strings to their lowercase equivalent.

StringNameSpace.to_uppercase()

Modify the strings to their uppercase equivalent.

StringNameSpace.zfill(alignment)

Return a copy of the string left filled with ASCII '0' digits to make a string of length width.

Lists

The following methods are available under the Series.arr attribute.

ListNameSpace.arg_max()

Retrieve the index of the maximum value in every sublist

ListNameSpace.arg_min()

Retrieve the index of the minimal value in every sublist

ListNameSpace.concat(other)

Concat the arrays in a Series dtype List in linear time.

ListNameSpace.contains(item)

Check if sublists contain the given item.

ListNameSpace.diff([n, null_behavior])

Calculate the n-th discrete difference of every sublist.

ListNameSpace.eval(expr[, parallel])

Run any polars expression against the lists' elements

ListNameSpace.first()

Get the first value of the sublists.

ListNameSpace.get(index)

Get the value by index in the sublists.

ListNameSpace.head([n])

Slice the head of every sublist

ListNameSpace.join(separator)

Join all string items in a sublist and place a separator between them.

ListNameSpace.last()

Get the last value of the sublists.

ListNameSpace.lengths()

Get the length of the arrays as UInt32.

ListNameSpace.max()

Compute the max value of the arrays in the list

ListNameSpace.mean()

Compute the mean value of the arrays in the list

ListNameSpace.min()

Compute the min value of the arrays in the list

ListNameSpace.reverse()

Reverse the arrays in the list

ListNameSpace.shift([periods])

Shift the values by a given period and fill the parts that will be empty due to this operation with nulls.

ListNameSpace.slice(offset, length)

Slice every sublist

ListNameSpace.sort([reverse])

Sort the arrays in the list

ListNameSpace.sum()

Sum all the arrays in the list

ListNameSpace.tail([n])

Slice the tail of every sublist

ListNameSpace.unique()

Get the unique/distinct values in the list

Categories

The following methods are available under the Series.cat attribute.

CatNameSpace.set_ordering(ordering)

Determine how this categorical series should be sorted.

Struct

The following methods are available under the Series.struct attribute.

StructNameSpace.field(name)

Retrieve one of the fields of this Struct as a new Series

StructNameSpace.fields

Get the names of the fields

StructNameSpace.rename_fields(names)

Rename the fields of the struct

StructNameSpace.to_frame()

Convert this Struct Series to a DataFrame