How can I create the type column recycling a two-elements list ["lat","lon"]?    adresse coord type     "place 1" 48.943837 lat   "place 1" 2.387917 lon   "place 2" 37.843837 lat   "place 2" 6.387917 lon    As it would be automatically done in R with d$type <- c("lat","lon") Reprex : d0 = pl.DataFrame( { "adresse": ["place 1", "place 2"], "coord": [[48.943837, 2.387917], [37.843837, 6.387917]], } ) d1 = d0.explode("coord")  What I tried: d1 = d1.with_columns(type=pl.Series(["1","2"])) # ShapeError: unable to add a column of length 2 to a DataFrame of height 4 d1 = d1.join(pl.DataFrame({"id":["1", "2"]}), how="cross") # logically, 8 rows instead of 4 
 pl.int_range() and pl.len() to create a "row number". pl.Expr.over() to do it within adresse column.  ( d0.explode("coord") .with_columns( type = pl.int_range(pl.len()).over("adresse") ) )  shape: (4, 3) ┌─────────┬───────────┬──────┐ │ adresse ┆ coord ┆ type │ │ --- ┆ --- ┆ --- │ │ str ┆ f64 ┆ i64 │ ╞═════════╪═══════════╪══════╡ │ place 1 ┆ 48.943837 ┆ 0 │ │ place 1 ┆ 2.387917 ┆ 1 │ │ place 2 ┆ 37.843837 ┆ 0 │ │ place 2 ┆ 6.387917 ┆ 1 │ └─────────┴───────────┴──────┘  Or if you need polars.datatypes.Enum(): dtype = pl.Enum(["lat", "lon"]) ( d0.explode("coord") .with_columns( type = pl.int_range(pl.len()).over("adresse").cast(dtype) ) )  shape: (4, 3) ┌─────────┬───────────┬──────┐ │ adresse ┆ coord ┆ type │ │ --- ┆ --- ┆ --- │ │ str ┆ f64 ┆ enum │ ╞═════════╪═══════════╪══════╡ │ place 1 ┆ 48.943837 ┆ lat │ │ place 1 ┆ 2.387917 ┆ lon │ │ place 2 ┆ 37.843837 ┆ lat │ │ place 2 ┆ 6.387917 ┆ lon │ └─────────┴───────────┴──────┘  Alternatively, you can first create additional lists with pl.int_ranges() and then explode both lists together, so you don't need pl.Expr.over() aka window function. ( d0 .with_columns(type = pl.int_ranges(2)) # or using pl.col.coord.list.len() # .with_columns(type = pl.int_ranges(pl.col.coord.list.len())) .explode("coord", "type") .with_columns(type = pl.col.type.cast(dtype)) ) 