pola-rs/polars · error · TypeError
Categorical physical must be one of pl.UInt(8|16|32)
Error message
Categorical physical must be one of pl.UInt(8|16|32)
What it means
Error "Categorical physical must be one of pl.UInt(8|16|32)" thrown in pola-rs/polars.
Source
Thrown at py-polars/src/polars/datatypes/classes.py:774
physical: PolarsDataType = pldt.UInt32,
) -> None:
if name is None or name == "":
assert namespace == "", "global categories may not specify a namespace"
assert physical == pldt.UInt32, (
"global categories may not specify a physical type"
)
self._categories = PyCategories.global_categories()
return
if physical == pldt.UInt32:
internal_phys = "u32"
elif physical == pldt.UInt16:
internal_phys = "u16"
elif physical == pldt.UInt8:
internal_phys = "u8"
else:
msg = "Categorical physical must be one of pl.UInt(8|16|32)"
raise TypeError(msg)
self._categories = PyCategories(name, namespace, internal_phys)
@staticmethod
def _from_py_categories(py_categories: PyCategories) -> Categories:
self = Categories.__new__(Categories)
self._categories = py_categories
return self
@staticmethod
def random(
namespace: str = "", physical: PolarsDataType = pldt.UInt32
) -> Categories:
"""
Creates a new `Categories` with a random name.
Parameters
----------View on GitHub (pinned to df599052da)
When it happens
Trigger: Thrown at py-polars/src/polars/datatypes/classes.py:774 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/3e04bd3c79e5bc35.
Report an issue: GitHub.