Hallo, ich habe einen Polars-Datenframe mit einer Spalte, die Listen von Listen enthält.import polars as pl
df = pl.DataFrame({
"nodes": [[[1], [1,2], []], [[2]], [[1], [2]]]
})
< /code>
shape: (3, 1)
┌───────────────────┐
│ nodes │
│ --- │
│ list[list[i64]] │
╞═══════════════════╡
│ [[1], [1, 2], []] │
│ [[2]] │
│ [[1], [2]] │
└───────────────────┘
< /code>
I want to merge all these sublists into one single list like this:
shape: (3, 1)
┌───────────┐
│ nodes │
│ --- │
│ list[i64] │
╞═══════════╡
│ [1, 1, 2] │
│ [2] │
│ [1, 2] │
└───────────┘
< /code>
I am pretty sure that must be doable pretty easily but I don't find the correct way in the API. Thanks for any help!
Listen der Listen in Polaren verschmelzen oder abflachen ⇐ Python
-
- Similar Topics
- Replies
- Views
- Last post