Series

Constructor

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

A Series represents a single column in a polars DataFrame.

Attributes

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.arr

Create an object namespace of all list related methods.

Series.dt

Create an object namespace of all datetime related methods.

Series.str

Create an object namespace of all string related methods.

Series.time_unit

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

Conversion

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_arrow()

Get the underlying Arrow Array.

Series.to_numpy(*args[, zero_copy_only])

Convert this Series to numpy.

Aggregation

Series.sum()

Reduce this Series to the sum value.

Series.mean()

Reduce this Series to the mean value.

Series.min()

Get the minimal value in this Series.

Series.max()

Get the maximum value in this Series.

Series.std([ddof])

Get the standard deviation of this Series.

Series.var([ddof])

Get variance of this Series.

Series.median()

Get the median of this Series.

Series.quantile(quantile[, interpolation])

Get the quantile value of this Series.

Series.product()

Reduce this Series to the product value.

Series.mode()

Compute the most occurring value(s).

Series.arg_min()

Get the index of the minimal value.

Series.arg_max()

Get the index of the maximal value.

Descriptive stats

Series.describe()

Quick summary statistics of a series.

Series.value_counts()

Count the unique values in a Series.

Series.chunk_lengths()

Get the length of each individual chunk.

Series.n_chunks()

Get the number of chunks that this Series contains.

Series.null_count()

Count the null values in this Series.

Series.is_null()

Get mask of null values.

Series.is_not_null()

Get mask of non null values.

Series.is_finite()

Get mask of finite values if Series dtype is Float.

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_in(other)

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

Series.is_unique()

Get mask of all unique values.

Series.is_first()

Get a mask of the first unique value.

Series.is_duplicated()

Get mask of all duplicated values.

Series.is_numeric()

Check if this Series datatype is numeric.

Series.is_float()

Check if this Series has floating point numbers.

Series.is_boolean()

Check if this Series is a Boolean.

Series.is_utf8()

Checks if this Series datatype is a Utf8.

Series.is_datelike()

Check if this Series datatype is datelike.

Series.len()

Length of this Series.

Series.n_unique()

Count the number of unique values in this Series.

Series.has_validity()

Returns True if the Series has a validity bitmask.

Boolean

Series.any()

Check if any boolean value in the column is True

Series.all()

Check if all boolean values in the column are True

Computations

Series.cumsum([reverse])

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

Series.cummin([reverse])

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

Series.cummax([reverse])

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

Series.cumprod([reverse])

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

Series.arg_true()

Get index values where Boolean Series evaluate True.

Series.arg_unique()

Get unique index as Series.

Series.unique()

Get unique elements in series.

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

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

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_sum(window_size[, weights, ...])

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

Series.rolling_apply(function, window_size)

Allows a custom rolling window function.

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

Compute a rolling std dev

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

Compute a rolling variance.

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

Compute a rolling median

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

Compute a rolling quantile

Series.rolling_skew(window_size[, bias])

Compute a rolling skew

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.hash([k0, k1, k2, k3])

Hash the Series.

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.dot(other)

Compute the dot/inner product between two Series

Series.abs()

Take absolute values

Series.rank([method, reverse])

Assign ranks to data, dealing with ties appropriately.

Series.diff([n, null_behavior])

Calculate the n-th discrete difference.

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.skew([bias])

Compute the sample skewness of a data set.

Series.kurtosis([fisher, bias])

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

Series.sqrt()

Compute the square root of the elements

Series.sin()

Compute the element-wise value for Trigonometric sine.

Series.cos()

Compute the element-wise value for Trigonometric cosine.

Series.tan()

Compute the element-wise value for Trigonometric tangent.

Series.arcsin()

Compute the element-wise value for Trigonometric Inverse sine.

Series.arccos()

Compute the element-wise value for Trigonometric Inverse cosine.

Series.arctan()

Compute the element-wise value for Trigonometric Inverse tangent.

Series.log()

Natural logarithm, element-wise.

Series.log10()

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

Series.exp()

Return the exponential element-wise

Manipulation/ selection

Series.alias(name)

Rename the Series

Series.rename()

Rename this Series.

Series.limit([num_elements])

Take n elements from this Series.

Series.slice(offset, length)

Get a slice of this Series.

Series.append(other)

Append a Series to this one.

Series.filter(predicate)

Filter elements by a boolean mask.

Series.head([length])

Get first N elements as Series.

Series.tail([length])

Get last N elements as Series.

Series.take_every(n)

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

Series.sort()

Sort this Series.

Series.argsort([reverse])

Index location of the sorted variant of this Series.

Series.take(indices)

Take values by index.

Series.shrink_to_fit()

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

Series.explode()

Explode a list or utf8 Series.

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

Sample from this Series by setting either n or frac.

Series.view([ignore_nulls])

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

Series.set(filter, value)

Set masked values.

Series.clone()

Cheap deep clones.

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.drop_nulls()

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

Series.rechunk()

Create a single chunk of memory for this Series.

Series.cast(dtype[, strict])

Cast between data types.

Series.round(decimals)

Round underlying floating point data by decimals digits.

Series.floor()

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

Series.ceil()

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

Series.set_at_idx(idx, value)

Set values at the index locations.

Series.fill_null(strategy)

Fill null values with a filling strategy.

Series.fill_nan(fill_value)

Fill floating point NaN value with a fill value

Series.zip_with(mask, other)

Where mask evaluates true, take values from self.

Series.interpolate()

Interpolate intermediate values.

Series.clip(min_val, max_val)

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

Series.str_concat([delimiter])

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

Series.reshape(dims)

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

Series.to_dummies()

Get dummy variables.

Series.shuffle([seed])

Shuffle the contents of this Series.

Series.extend(value, n)

Extend the Series with given number of values.

Various

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

Check if series is equal with another Series.

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.str

Create an object namespace of all string related methods.

Series.reinterpret([signed])

Reinterpret the underlying bits as a signed/unsigned integer.

Series.to_physical()

Cast to physical representation of the logical dtype.

TimeSeries

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

DateTimeNameSpace.strftime(fmt)

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

DateTimeNameSpace.year()

Extract the year from the underlying date representation.

DateTimeNameSpace.month()

Extract the month from the underlying date representation.

DateTimeNameSpace.week()

Extract the week from the underlying date representation.

DateTimeNameSpace.weekday()

Extract the week day from the underlying date representation.

DateTimeNameSpace.day()

Extract the day from the underlying date representation.

DateTimeNameSpace.ordinal_day()

Extract ordinal day from underlying date representation.

DateTimeNameSpace.hour()

Extract the hour from the underlying DateTime representation.

DateTimeNameSpace.minute()

Extract the minutes from the underlying DateTime representation.

DateTimeNameSpace.second()

Extract the seconds the from underlying DateTime representation.

DateTimeNameSpace.nanosecond()

Extract the nanoseconds from the underlying DateTime representation.

DateTimeNameSpace.timestamp()

Return timestamp in ms as Int64 type.

DateTimeNameSpace.to_python_datetime()

Go from Date/Datetime to python DateTime objects

DateTimeNameSpace.min()

Return minimum as python DateTime

DateTimeNameSpace.max()

Return maximum as python DateTime

DateTimeNameSpace.median()

Return median as python DateTime

DateTimeNameSpace.mean()

Return mean as python DateTime

DateTimeNameSpace.truncate(every[, offset])

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.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.days()

Extract the days from a Duration type.

DateTimeNameSpace.hours()

Extract the hours from a Duration type.

DateTimeNameSpace.seconds()

Extract the seconds from a Duration type.

DateTimeNameSpace.milliseconds()

Extract the milliseconds from a Duration type.

DateTimeNameSpace.nanoseconds()

Extract the nanoseconds from a Duration type.

Strings

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

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

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

StringNameSpace.lengths()

Get length of the string values in the Series.

StringNameSpace.contains(pattern)

Check if strings in Series contain regex pattern.

StringNameSpace.json_path_match(json_path)

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

StringNameSpace.extract(pattern[, group_index])

Extract the target capture group from provided patterns.

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.to_lowercase()

Modify the strings to their lowercase equivalent.

StringNameSpace.to_uppercase()

Modify the strings to their uppercase equivalent.

StringNameSpace.strip()

Remove leading and trailing whitespace.

StringNameSpace.rstrip()

Remove trailing whitespace.

StringNameSpace.lstrip()

Remove leading whitespace.

StringNameSpace.slice(start[, length])

Create subslices of the string values of a Utf8 Series.

StringNameSpace.encode(encoding)

Encodes a value using the provided encoding

StringNameSpace.decode(encoding[, strict])

Decodes a value using the provided encoding

Lists

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

ListNameSpace.concat(other)

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

ListNameSpace.lengths()

Get the length of the arrays as UInt32.

ListNameSpace.sum()

Sum all the arrays in the list

ListNameSpace.min()

Compute the min value of the arrays in the list

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.sort([reverse])

Sort the arrays in the list

ListNameSpace.reverse()

Reverse the arrays in the list

ListNameSpace.unique()

Get the unique/distinct values in the list

ListNameSpace.get(index)

Get the value by index in the sublists.

ListNameSpace.first()

Get the first value of the sublists.

ListNameSpace.last()

Get the last value of the sublists.

ListNameSpace.contains(item)

Check if sublists contain the given item.