You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is correct. This will be more clear with the new mapping strategy argument released.
The default strategy of a window expression is "group_to_idx".
Maybe this makes it more clear:
df=pl.DataFrame({
'type': ['water','fire','water','earth']
})
df.select(
pl.all(),
pl.col('type').over('type', mapping_strategy="join").alias("join"),
pl.col('type').over('type', mapping_strategy="group_to_rows").alias("g2r"),
pl.col('type').implode().arr.head(1).over('type', mapping_strategy="join").alias("this cannot be mapped to rows, as it doesn't have enough elements")
)
shape: (4, 4)
┌───────┬────────────────────┬───────┬───────────────────────────────────┐
│ type ┆ join ┆ g2r ┆ this cannot be mapped to rows, a… │
│ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ list[str] ┆ str ┆ list[str] │
╞═══════╪════════════════════╪═══════╪═══════════════════════════════════╡
│ water ┆ ["water", "water"] ┆ water ┆ ["water"] │
│ fire ┆ ["fire"] ┆ fire ┆ ["fire"] │
│ water ┆ ["water", "water"] ┆ water ┆ ["water"] │
│ earth ┆ ["earth"] ┆ earth ┆ ["earth"] │
└───────┴────────────────────┴───────┴───────────────────────────────────┘
Polars version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of Polars.
Issue description
While testing out the flatten behaviour in #8965 - I noticed using
.arr.head(1)
raised an exception..arr.slice(0, 1)
raises the same exception, but.arr.first()
succeeds.Oddly enough
.arr.head(2)
also succeeds but returns the same output as.arr.first()
which doesn't seem right?Reproducible example
Expected behavior
No exception.
Installed versions
The text was updated successfully, but these errors were encountered: