0

How can I convert a list wit one element like this: [[1.0, 0.0, nan]] into a real list with lenght 3

convert `[[1.0, 0.0, nan]]`(lenght=1) into [1.0, 0.0, nan]`(lenght=3)

2 Answers2

2

Just access the first value:

a = [[1.0, 0.0, nan]]
b = a[0]
flakes
  • 21,558
  • 8
  • 41
  • 88
  • why excactly i had to do this ? – 124747chdhsgxj Feb 10 '21 at 16:30
  • @124747chdhsgxj `a` is a list of lists. To access the first list in the list of lists, you would use the square bracket `list[i]` accessor. See https://www.programiz.com/python-programming/list – flakes Feb 10 '21 at 16:32
0

Simply access the zeroth index of your list which will give you an list of length 3

data=data[0] should do the job

print(data) // [1.0, 0.0, nan]
Utpal Dutt
  • 383
  • 3
  • 18