import numpy as np
import pandas as pd
d = {'user': [1.0, 2.0, 3.0, 4], 'item': [5.0, 6.0, 7.0, 8.0], 'f1': [9.0, 
    16.0, 17.0, 18.0], 'f2': [4, 5, 6, 5], 'f3': [4, 5, 5, 8]}
df = pd.DataFrame(d)
samples = np.array([[1, 5], [3, 7], [3, 7], [2, 6]])
samples = pd.DataFrame(samples, columns=['user', 'item'])
result = pd.merge(samples, df, how='inner')
result = result[['f1', 'f2', 'f3']]
result = result.values
print(result)
Select pandas frame rows based on two columns' values