doctors and patients arrays are parallel. Data says, for example, the doctor named Benitz has 172 patients in 2017, the doctor Modin has 272 patients in 2019 and so on. I'd like to extract the doctor name data for year 2019 into an array, which is ['Modin' 'Vandergard']. I did this by the code below, but as you see, I firstly use list, append method and then turn the list into an array. I wonder if there is more practical solution without using lists. I mean, is there any way to solve it by just using arrays?
import numpy as np
doctors=np.array(['Benitz','Modin','Leabow','Vandergard'])
patients=np.array([[2017,172],
[2019,272],
[2016,203],
[2019,250]])
doc2019_list=[]
for row in range(0,len(patients)):
for col in range(0,len(patients[row])):
if patients[row][col]==2019:
doc2019_list.append(doctors[row])
doc2019=np.array(doc2019_list)
print(doc2019)