I am trying to make my current code dynamic. Meaning it should be able to adjust regardless of the number of array inputs of the user.
Current code:
main1 = numpy.array([1,2,3,4])
array1 = numpy.array(['a','b','c','b'])
my_list1 = ['a','b']
array2 = numpy.array(['cat','dog','bird','cat'])
my_list2 = ['cat']
result_array = main1[np.in1d(array1, my_list1) and np.in1d(array2, my_list2)]
The desired result of printing out result_array is:
array([1, 4])
This is because of the intersection of a and cat & b and cat.
My goal is to be able to do this with an n number of array1, array2 ... and n number of my_list1, my_list2...
Thanks in advance!