facebook / facebook/pyrefly

Support Polars DataFrame.unpivot schema inference

Open
#4,566 5 comments 0 reactions 1 assignee Claimed by @alexander-beedie View on GitHub
dataframe
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

Calling `DataFrame.unpivot` falls back to a bare `DataFrame`, even when its output schema can be determined statically.

```python
from typing import reveal_type

import polars as pl

df = pl.DataFrame({
"region": ["East"],
"units": [12],
"price": [1.5],
})

reveal_type(df.unpivot(index="region", on=["units", "price"])) # DataFrame
```

I would expect:

```text
DataFrame[region: String, variable: String, value: Float64]
```

Reproduced on `pyrefly 1.3.0-dev.1` with Polars 1.35.2.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.