{"record":{"id":"de28a7cb9b747063","repo":"pola-rs/polars","slug":"cannot-describe-a-lazyframe-that-has-no-columns","errorCode":null,"errorMessage":"cannot describe a LazyFrame that has no columns","messagePattern":"cannot describe a LazyFrame that has no columns","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/lazyframe/frame.py","lineNumber":1161,"sourceCode":"        │ null_count ┆ 0.0      ┆ 1.0      ┆ 0.0      ┆ 0    ┆ 0                   ┆ 0        │\n        │ mean       ┆ 2.266667 ┆ 45.0     ┆ 0.666667 ┆ null ┆ 2021-07-02 16:00:00 ┆ 16:07:10 │\n        │ std        ┆ 1.101514 ┆ 7.071068 ┆ null     ┆ null ┆ null                ┆ null     │\n        │ min        ┆ 1.0      ┆ 40.0     ┆ 0.0      ┆ xx   ┆ 2020-01-01          ┆ 10:20:30 │\n        │ 10%        ┆ 1.36     ┆ 41.0     ┆ null     ┆ null ┆ 2020-04-20          ┆ 11:13:34 │\n        │ 30%        ┆ 2.08     ┆ 43.0     ┆ null     ┆ null ┆ 2020-11-26          ┆ 12:59:42 │\n        │ 50%        ┆ 2.8      ┆ 45.0     ┆ null     ┆ null ┆ 2021-07-05          ┆ 14:45:50 │\n        │ 70%        ┆ 2.88     ┆ 47.0     ┆ null     ┆ null ┆ 2022-02-07          ┆ 18:09:34 │\n        │ 90%        ┆ 2.96     ┆ 49.0     ┆ null     ┆ null ┆ 2022-09-13          ┆ 21:33:18 │\n        │ max        ┆ 3.0      ┆ 50.0     ┆ 1.0      ┆ zz   ┆ 2022-12-31          ┆ 23:15:10 │\n        └────────────┴──────────┴──────────┴──────────┴──────┴─────────────────────┴──────────┘\n        \"\"\"  # noqa: W505\n        from polars.convert import from_dict\n\n        schema = self.collect_schema()\n\n        if not schema:\n            msg = \"cannot describe a LazyFrame that has no columns\"\n            raise TypeError(msg)\n\n        # create list of metrics\n        metrics = [\"count\", \"null_count\", \"mean\", \"std\", \"min\"]\n        if quantiles := parse_percentiles(percentiles):\n            metrics.extend(f\"{q * 100:g}%\" for q in quantiles)\n        metrics.append(\"max\")\n\n        @lru_cache\n        def skip_minmax(dt: PolarsDataType) -> bool:\n            return (\n                dt.is_nested()\n                or dt.is_extension()\n                or dt in (Categorical, Enum, Null, Object, Unknown)\n            )\n\n        # determine which columns will produce std/mean/percentile/etc\n        # statistics in a single pass over the frame schema\n        has_numeric_result, sort_cols = set(), set()","sourceCodeStart":1143,"sourceCodeEnd":1179,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/lazyframe/frame.py#L1143-L1179","documentation":"LazyFrame.describe() computes summary statistics per column, which is impossible when the frame's collected schema is empty (zero columns). Polars raises a TypeError rather than returning an empty summary.","triggerScenarios":"`lf.describe()` on an empty-schema frame, e.g. `pl.LazyFrame()`, or after a select() that drops all columns.","commonSituations":"Describing dynamically-built frames where upstream selects removed every column; conditional column selection yielding zero columns; empty templates not yet populated.","solutions":["Guard with `if lf.collect_schema(): lf.describe()` before calling","Ensure the pipeline retains at least one column before describing","Row-empty frames with columns are fine — only zero-column schemas fail"],"exampleFix":"// before\nsummary = lf.describe()\n\n// after\nsummary = lf.describe() if lf.collect_schema() else None","handlingStrategy":"validation","validationCode":"schema = lf.collect_schema()\nif not schema:\n    raise ValueError(\"LazyFrame has no columns; cannot describe\")","typeGuard":"def describable(lf: pl.LazyFrame) -> bool:\n    return len(lf.collect_schema()) > 0","tryCatchPattern":"try:\n    summary = lf.describe()\nexcept TypeError as e:\n    if \"no columns\" in str(e):\n        summary = None\n    else:\n        raise","preventionTips":["Check collect_schema() non-empty before describe()","Avoid select() chains that can drop all columns","Handle empty schemas at pipeline boundaries"],"tags":["python","polars","lazyframe","empty-schema"],"backgroundTag":"empty-required-field","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}