I have a numpy array of over 2 million ints:
a = np.array([324, 986, 574 ... 986, 1232, 3943])
Each element in a corresponds to an index value in a dataframe df with shape (1324, 4):
index A B C D
0 'foo' 2 3 2
1 'bar' 2 4 8
...
1323 'foo' 2 5 8
I am trying to access the values of df.A using a list comprehension:
l = [df.A.loc[i] for i in a]
but this is taking quite a long time to run. Is there a faster option; maybe I need to do a join? Thank you.