Marc Zaharescu - 2 months ago 14

Python Question

I have the following data types

`A=[1,2,3]`

B=[['A', 'C'], ['B', 'C'], ['A', 'B']]

C=[[0 2]

[1 2]

[2 1]]

I want to form a

`new_matrix`

`index new_value1 new_value2`

1 1 ['A','C'] [0,2]

2 2 ['B','C'] [1,2]

3 3 ['A','B'] [2,1]

where the

`index`

`A`

`new_value1`

`B`

`new_value2`

`C`

Any help would be much appreaciated.

Answer

Put your variables in a dictionary, and create a data frame using that dictionary:

```
a = dict(
index=[1,2,3],
new_value1=[['A', 'C'], ['B', 'C'], ['A', 'B']],
new_value2=[[0, 2], [1, 2], [2, 1]]
)
pd.DataFrame(a)
```