0
$\begingroup$

i have a dataframe with 2 series, i want to create new column that has 1 if if start word of array one series is equal to start word of another series else 0. How do I do it? i am using polars, it seems a little complex than pandas.

dff = pl.DataFrame({"foo": [[1,3,3,3,], [3,5,3,4], [4,7,5,3]], "bar": [[3,345,3,4], [3,4,334,2], [4,52,4,2]]})
shape: (3, 2)
┌─────────────┬───────────────┐
│ foo         ┆ bar           │
│ ---         ┆ ---           │
│ list[i64]   ┆ list[i64]     │
╞═════════════╪═══════════════╡
│ [1, 3, … 3] ┆ [3, 345, … 4] │
│ [3, 5, … 4] ┆ [3, 4, … 2]   │
│ [4, 7, … 3] ┆ [4, 52, … 2]  │
└─────────────┴───────────────┘

like 'common start': [0,1,1]

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.