Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Polars · Class

pl.Series

polars.Series creates a one-dimensional, typed column from supported array-like data. You can provide its name and dtype, or let Polars infer the dtype from the values.

How it works

polars.Series constructs a typed, one-dimensional column from supported array-like input. You may provide a name and dtype; otherwise the name defaults to an empty string and the dtype is inferred from the values, with inference behavior controlled by strict.

Syntax

polars.Series(name: str_ | ArrayLike | None = None, values: ArrayLike | None = None, dtype: PolarsDataType | None = None, *, strict: bool = True, nan_to_null: bool = False)

Parameters

NameTypeDescription
namestr_ | ArrayLike | NoneSeries name; used as the DataFrame column name, and defaults to an empty string when omitted.
valuesArrayLike | NoneOne-dimensional input data; supported forms include a sequence, Series, PyArrow Array, or NumPy ndarray.
dtypePolarsDataType | NoneResulting Polars data type. If omitted, it is inferred from values.
strictboolControls strictness of type inference and conversion; defaults to True.
nan_to_nullboolFor NumPy input, controls whether NaN values are converted to null; defaults to False and is ineffective for other inputs.

Returns

A polars.Series object representing a single column.

Key points

  • A Series is Polars' one-dimensional column abstraction and can serve as a DataFrame column.
  • The constructor accepts an optional name, including string-like or array-like name input.
  • Values are optional one-dimensional data supplied through the values argument.
  • Supported construction inputs include Python sequences, Series, PyArrow arrays, and NumPy ndarrays.
  • An explicit Polars data type can be supplied through dtype.
  • Without an explicit dtype, Polars infers the resulting type from the input values.
  • Omitting the name gives the Series an empty-string name.

Common mistakes

  • With the default strict inference, the first non-null value determines the inferred data type.
  • nan_to_null only affects Series created from NumPy arrays.

Example: Create a Series

import polars as pl

s = pl.Series("values", [1, 2, 3])
print(s)
print(s.dtype)

Creates a named Series from one-dimensional values; Polars infers the integer data type.

When to use it

Build a column

Create a named column from Python values before building or modifying a DataFrame.

Control schema

Preserve a chosen Polars type instead of relying on input-based inference.

Normalize missing values

Convert NumPy NaN values to Polars nulls during construction.

Interview questions

QWhat is a Polars Series, and what inputs can construct one?

Series represents a single column in a Polars DataFrame. It is one-dimensional and can be constructed from supported array-like inputs such as sequences, another Series, PyArrow arrays, or NumPy ndarrays.

Follow-up: How does dtype inference differ when strict is enabled? With strict inference, the inferred type follows the first non-null value; incompatible later values can raise an error.

QWhat does the name parameter control?

The name argument supplies the Series name and becomes the column name when the Series is used in a DataFrame. If omitted, the name is an empty string.

Follow-up: What happens when the Series is inserted into a DataFrame without a name? It carries the empty-string name unless renamed before insertion.

QHow do dtype, strict, and nan_to_null affect construction?

dtype explicitly sets the resulting data type. When it is None, Polars infers the type from values; strict controls whether incompatible values cause failure or are converted to null where possible.

Follow-up: When would nan_to_null matter? It matters for NumPy input when NaN values should be represented as null; it has no effect on non-NumPy input.

  • polars.DataFrame
  • polars.Series.item
  • polars.Series.__getitem__
  • polars.Series.alias

Source: Series — Polars documentation. Checked 2026-10-15.