Reputation: 1293
I have a Dataframe that has two columns as below:
col_a,col_b
10,32
23,43
32,64
I am trying to get the Dataframe converted to the below format:
[(10,32),(23,43),(32,64)]
Upvotes: 0
Views: 41
Reputation: 862711
Use list comprehension or map with convert lists to tuples:
L = [tuple(x) for x in df.values.tolist()]
L = list(map(tuple, df.values.tolist()))
Another solution with zip
and transpose:
L = list(zip(*df.T.values.tolist()))
print (L)
[(10, 32), (23, 43), (32, 64)]
Upvotes: 1