Python Forum
Find Value in Array - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Find Value in Array (/thread-11388.html)



Find Value in Array - rizals - Jul-06-2018

Hallo All

I find some value in array but i have not result, what's wrong with my code

VV = np.arange(min(dV),max(dV),.1)
for i in range(len(VV)):
    if VV[i] == 5.0:
       print("Values VV = ",VV[i])
       dIdVsat=xp1[i]
       break



RE: Find Value in Array - DeaD_EyE - Jul-06-2018

You're working with floats and you should never compare floats on equality.
You can misuse np.searchsorted.
x = np.arange(1,10,.1)
# x is sorted
index = x.searchsorted(5)
# finds the index where to insert the value 5 to keep the order
print('Index:', index, 'Value:', x[index])
# prints the result
You should visit this page: https://0.30000000000000004.com/


RE: Find Value in Array - rizals - Jul-06-2018

OK, thank you very much for explained