0
df1 = pd.DataFrame({'user': ['Bob','Bob','Bob'],'income':[400,500, 420],'expenses':[400,2500,420]})
df1.user.unique()

return_val = df[(df['Payer']=='Bob')]

I have two dataframes (df and df1) and I do not want to hard code 'Bob' in return_val. Is there anyway through which I can get 'Bob' by reading df1 ? Am trying something like this which seems incomplete.

return_val = df[(df['Payer']== df1.user.unique())]
Akash
  • 59
  • 7

1 Answers1

0
mask=df1['user'].unique()[0]
return_val = df[mask]

but it work only if you have 'Bob' only in the 'user' column

Mohammed Khalid
  • 155
  • 1
  • 6
  • Yes. there is only 'Bob' in the column. There are multiple files having different user names. – Akash Feb 13 '20 at 20:49