[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of Polars.
Reproducible example
import polars as pl
df = pl.DataFrame(
{
"cl1": [[0], [0]],
"cl2": [[0], [0]],
}
)
df_row_1 = df[1] # index 0 works and any others fail
df_row_1 = df_row_1.select(
pl.col("cl1"),
pl.concat_list(pl.col("cl2")) # without pl.concat it works as well
)
df_row_1.explode(pl.all())
Log output
---------------------------------------------------------------------------
ShapeError Traceback (most recent call last)
Cell In[6], line 16
10 df_row_1 = df[1]
11 df_row_1 = df_row_1.select(
12 pl.col("cl1"),
13 pl.concat_list(pl.col("cl2"))
14 )
---> 16 df_row_1.explode(pl.all())
File ~/miniconda3/envs/x/lib/python3.12/site-packages/polars/dataframe/frame.py:7193, in DataFrame.explode(self, columns, *more_columns)
7136 def explode(
7137 self,
7138 columns: str | Expr | Sequence[str | Expr],
7139 *more_columns: str | Expr,
7140 ) -> DataFrame:
7141 """
7142 Explode the dataframe to long format by exploding the given columns.
7143
(...)
7191 └─────────┴─────────┘
7192 """
-> 7193 return self.lazy().explode(columns, *more_columns).collect(_eager=True)
File ~/miniconda3/envs/x/lib/python3.12/site-packages/polars/lazyframe/frame.py:1816, in LazyFrame.collect(self, type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, no_optimization, streaming, background, _eager, **_kwargs)
1813 # Only for testing purposes atm.
1814 callback = _kwargs.get("post_opt_callback")
-> 1816 return wrap_df(ldf.collect(callback))
ShapeError: exploded columns must have matching element counts
Issue description
When indexing the non first row, having a list column and concatenating a list column the following explode() can fail with a shape error
Checks
Reproducible example
Log output
Issue description
When indexing the non first row, having a list column and concatenating a list column the following
explode()
can fail with a shape errorExpected behavior
Installed versions