pola-rs/polars · error · TypeError
Array constructor is missing the required argument `shape`
Error message
Array constructor is missing the required argument `shape`
What it means
Error "Array constructor is missing the required argument `shape`" thrown in pola-rs/polars.
Source
Thrown at py-polars/src/polars/datatypes/classes.py:1230
def __init__(
self,
inner: PolarsDataType | PythonDataType,
shape: int | tuple[int, ...] | None = None,
*,
width: int | None = None,
) -> None:
if width is not None:
from polars._utils.deprecation import issue_deprecation_warning
issue_deprecation_warning(
"the `width` parameter for `Array` is deprecated. Use `shape` instead.",
version="0.20.31",
)
shape = width
elif shape is None:
msg = "Array constructor is missing the required argument `shape`"
raise TypeError(msg)
inner_parsed = polars.datatypes.parse_into_dtype(inner)
inner_shape = inner_parsed.shape if isinstance(inner_parsed, Array) else ()
if isinstance(shape, int):
self.inner = inner_parsed
self.size = shape
self.shape = (shape,) + inner_shape
elif isinstance(shape, tuple) and isinstance(shape[0], int): # type: ignore[redundant-expr]
if len(shape) > 1:
inner_parsed = Array(inner_parsed, shape[1:])
self.inner = inner_parsed
self.size = shape[0]
self.shape = shape + inner_shape
else:View on GitHub (pinned to df599052da)
When it happens
Trigger: Thrown at py-polars/src/polars/datatypes/classes.py:1230 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pola-rs/polars@df599052da (2026-08-16).
Data as JSON: /api/errors/ead5b3c50bf2bf03.
Report an issue: GitHub.