I am reading a csv to a dataframe and want to pull out a column from that dataframe and turn it into a list of lists. The data in the column looks like this:
[(123, 456), (789, 101), (321, 654), (098, 765), (432, 213), (856, 987)]
I want to create a list of lists like so:
list_of_lists = [ [123, 456], [789, 101], [321, 654], [098, 765], [432, 213], [856, 987] ]
I’ve tried pulling out that column by using tolist():
new_list = df['column_name'].tolist()
but that gives me a list of list of list of tuples like this:
['[(123, 456), (789, 101), (321, 654)]', '[(098, 765), (432, 213), (856, 987)]']
I’ve tried using list comprehension after tolist():
[list(elem) for elem in new_list]
and a bunch of other variations of list comprehension but the nested layers make this complex.