I have a list of lists, that every list contains a string. I want to convert every string in the list to float numbers. Instead of having one element in the list ( a string ), I want my list to contain multiple floats
[['1,10,300,0.5,85'],
['3,16,271,2.9,89'],...
To:
[[1,10,300,0.5,85],
[3,16,271,2.9,89],...
How can i do it? Thank you
x = [['1,10,300,0.5,85'], ['3,16,271,2.9,89']]
y = [[float(v) for v in r[0].split(',')] for r in x]
y
will be
[[1.0, 10.0, 300.0, 0.5, 85.0], [3.0, 16.0, 271.0, 2.9, 89.0]]