pola-rs/polars · error · TypeError
DataTypeExpr.collect_dtype did not expect {context!r}
Error message
DataTypeExpr.collect_dtype did not expect {context!r} What it means
Error "DataTypeExpr.collect_dtype did not expect {context!r}" thrown in pola-rs/polars.
Source
Thrown at py-polars/src/polars/datatype_expr/datatype_expr.py:302
... }
... )
>>> pl.dtype_of("a").collect_dtype(lf)
Int64
>>> pl.dtype_of("a").collect_dtype({"a": pl.String})
String
"""
schema: pl.Schema
if isinstance(context, pl.Schema):
schema = context
elif isinstance(context, Mapping):
schema = pl.Schema(context)
elif isinstance(context, pl.DataFrame):
schema = context.schema
elif isinstance(context, pl.LazyFrame):
schema = context.collect_schema()
else:
msg = f"DataTypeExpr.collect_dtype did not expect {context!r}"
raise TypeError(msg)
return self._pydatatype_expr.collect_dtype(schema)
View on GitHub (pinned to df599052da)
When it happens
Trigger: Thrown at py-polars/src/polars/datatype_expr/datatype_expr.py:302 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/4b3f886cd51b3a9e.
Report an issue: GitHub.