We have a table with array columns ids and scores. Each array has 5 elements. Suppose we want to create new table with column id_wise_scores by looping over multiple arrays simultaneously (by index), how do we do that in Python? Example:
| ids | scores | | --------------------- | ------------------------------------ | | [0, 1, 22, 56, 204] | [0.98, 0.56, 0.078, 0.23, 1.45] | | [0, 1, 22, 56, 204] | [0.68, 0.666, 3.56, 5.6, 0.078] | | [0, 1, 22, 56, 204] | [0.665, 0.298, 4.66, 0.0004, 0.45] | | [0, 1, 22, 56, 204] | [5.34, 1.34, 4.34, 0.23, 0.90] | | [0, 1, 22, 56, 204] | [0.009, 0.45, 1.22, 5.67, 2.23] | | [0, 1, 22, 56, 204] | [0.56, 0.67, 5.56, 1.64, 0.088] | | [0, 1, 22, 56, 204] | [0.34, 0.934, 3.42, 3.33, 0.40] |
We want to create id wise scores column.Expected result:
| id | id_wise_scores | | ---- | ---------------------------------------------- | | 0 | [0.98, 0.68, 0.665, 5.34, 0.009, 0.56, 0.34] | | 1 | [0.56, 0.666, 0.298, 1.34, 0.45, 0.67, 0.934] | | 22 | [0.078, 3.56, 4.66, 4.34, 1.22, 5.56, 3.42 ] | | 56 | [0.23, 5.6, 0.0004, 0.23, 5.67, 1.64, 3.33] | | 204 | [1.45, 0.078, 0.45, 0.90, 2.23, 0.088, 0.40] |
I tried using zip fiction for the same, but number of rows are huge doesn’t seem like working.