{"record":{"id":"927f2b46e1c196a7","repo":"pola-rs/polars","slug":"orient-must-be-one-of-col-row-none-got","errorCode":null,"errorMessage":"`orient` must be one of {'col', 'row', None}, got {orient!r}","messagePattern":"`orient` must be one of (.+?), got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/_utils/construction/dataframe.py","lineNumber":629,"sourceCode":"    elif orient == \"col\":\n        column_names, schema_overrides = _unpack_schema(\n            schema, schema_overrides=schema_overrides, n_expected=len(data)\n        )\n        data_series: list[PySeries] = [\n            pl.Series(\n                column_names[i],\n                element,\n                dtype=schema_overrides.get(column_names[i]),\n                strict=strict,\n                nan_to_null=nan_to_null,\n            )._s\n            for i, element in enumerate(data)\n        ]\n        return PyDataFrame(data_series)\n\n    else:\n        msg = f\"`orient` must be one of {{'col', 'row', None}}, got {orient!r}\"\n        raise ValueError(msg)\n\n\ndef _sequence_of_series_to_pydf(\n    first_element: Series,  # noqa: ARG001\n    data: Sequence[Any],\n    schema: SchemaDefinition | None,\n    *,\n    schema_overrides: SchemaDict | None,\n    strict: bool,\n    **kwargs: Any,  # noqa: ARG001\n) -> PyDataFrame:\n    series_names = [s.name for s in data]\n    column_names, schema_overrides = _unpack_schema(\n        schema or series_names,\n        schema_overrides=schema_overrides,\n        n_expected=len(data),\n    )\n    data_series: list[PySeries] = []","sourceCodeStart":611,"sourceCodeEnd":647,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/_utils/construction/dataframe.py#L611-L647","documentation":"The DataFrame constructor's `orient` parameter only accepts 'col', 'row', or None (auto-detection). Any other value — notably pandas/numpy-flavored spellings like 'columns', 'index', 'C'/'F' — fails this explicit ValueError at the end of orientation dispatch, before the data is processed further.","triggerScenarios":"`pl.DataFrame([[1, 2], [3, 4]], orient=\"columns\")`, `orient=\"rows\"`, `orient=\"index\"`, or any string other than 'col'/'row'; passing the value through a variable configured from pandas code.","commonSituations":"Code mechanically translated from pandas (where 'index'/'columns' are valid); autocomplete choosing the wrong literal; configuration shared between pandas and polars call sites.","solutions":["Use `orient=\"col\"` or `orient=\"row\"` — or omit orient entirely and let polars infer it (it warns only when square data is ambiguous)","Remember the mapping: 'row' means each inner sequence is a row; 'col' means each inner sequence is a column","For pandas interop prefer `pl.from_pandas(df)` instead of translating orient arguments"],"exampleFix":"# before\npl.DataFrame([[1, 2], [3, 4]], orient=\"columns\")\n# ValueError: `orient` must be one of {'col', 'row', None}, got 'columns'\n\n# after — rows as inner sequences\npl.DataFrame([[1, 2], [3, 4]], orient=\"row\")\n# or columns as inner sequences\npl.DataFrame([[1, 3], [2, 4]], orient=\"col\")","handlingStrategy":"validation","validationCode":"import polars as pl\n\ndef normalize_orient(orient: str | None) -> str | None:\n    mapping = {\"columns\": \"col\", \"index\": \"row\", \"rows\": \"row\", \"cols\": \"col\"}\n    orient = mapping.get(orient, orient)\n    if orient not in {\"col\", \"row\", None}:\n        raise ValueError(f\"invalid orient {orient!r}\")\n    return orient","typeGuard":"from typing import Literal\n\nOrient = Literal[\"col\", \"row\", None]\n\ndef is_valid_orient(value) -> bool:\n    return value is None or (isinstance(value, str) and value in {\"col\", \"row\"})","tryCatchPattern":"try:\n    df = pl.DataFrame(data, orient=orient)\nexcept ValueError as e:\n    if \"orient\" not in str(e):\n        raise\n    raise ValueError(f\"orient must be 'col'/'row'/None; got {orient!r} (pandas-style names are not accepted)\") from e","preventionTips":["Accept only 'col'/'row'/None in your own wrappers and reject early with a clear message","Translate pandas vocabulary at the boundary: 'columns'->'col', 'index'->'row'","Prefer pl.from_pandas for pandas data instead of orient translation"],"tags":["dataframe-construction","orient","invalid-argument","pandas-interop"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}