The following is a sample of 1 item in my list:
array([[ 1, 2, 3,
43, 83, 92],
[ 12, 54, 93,
23, 94, 83],
[ 23, inf, inf,
inf, inf, inf],
[ 83, 33, 33,
83, 13, 83],
[ 83, nan, 83,
73, 43, 43],
[ 43, 83, 93,
22, 83, 54],
[ 66, nan, 74,
84, 84, 75],
[ 74, 44, 65,
6, 9, 7],
[ 54, 9, 74,
754, 55, 74]])
Some of those items contain inf
or nan
values. I'm thus trying to return the index of the items that contain such values. I thus tried doing the following:
for x in f:
if float('inf') in x:
idx.append(f.index(x))
elif float('nan') in x:
idx.append(f.index(x))
When I run my script however, I get the following error:
idx.append(f.index(x))
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Why is that? How can I solve this issue?
As a reminder, the above sample is only 1 item. Since it contains inf
and nan
, I would like to return the index of that item. The item is basically a list of lists.
Thanks.