I have an array of values and I want to filter it by their two first characters.
Now my values are strings that always start with an identifier of two characters like 01, 02, 03... Thus I'm doing the following:
payloads = []
for pay in all_payloads:
if pay[:2] == '01':
payloads.append(pay)
I know I can do a list comprehension too, but actually what I want to learn if its possible to filter it directly with numpy. I thought maybe np.where() it's a good option but it's not working for me...
cosl = np.where(all_payloads[:2] == '01')
Can somebody help me to learn how to do it?
Sample inputs
['011b009f2e5141cc3c07be7756e0418a9ce6bc3e1ab13e9e1ffc3f0418943e00000000'
'011c00f51a51411de008be6f0fe541baa256bd85c2be3eb24af13fdbcb833e00000000'
'031d0086265141240401be873fea414b64e93b4d0a923e0723f33f2c95a63e00000000'
'011e00e62c5141a3e306be12c2ef4135d44a3c7b0e773eff51fb3f67da883e00000000'
'021e00e62c5141a3e306be12c2ef4135d44a3c7b0e773eff51fb3f67da883e00000000'
'011f0035335141f57107be6806f6410664e9bcd088983ee52ef13fb4b48b3e00000000'
'012000af405141521704be0184fd41d07752bd5eadb13ef0adf33fe4279c3e00000000'
'032100ae4351415a94fbbdf9e8024296710b3e4417c93fd77efa3f35b1043f00000000'
'01220015525141c20601be130e06423648f7bc9341a63e6c35fd3f6972943e00000000']
Thank you very much!