w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Create a vector with values from a Numpy array selected according to criteria in a Pandas DataFrame

How about this?

df.apply(lambda x:P[x[0],x[1]], axis=1)

It does what you describe, go row-wise (so apply over axis=1) along df and use the entries as index for selecting in P.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.