I just went through to this case:
I am trying to keep my code simple and clean. It feels I went overboard with this. and it seems to be to lengthy. Is there a short or better version to implement this ? Not even sure if it is the correct answer.
Thank you and I hope someone guide me if it is correct or show me better way to implement this
CodePudding user response:
You can filter your dataset by given sample Country and then check if given Broker is in your dataset.
Example:
sample_country = sample_df['Account Country'].values
sample_broker = sample_df['Broker'].values
if sample_broker.isin(dataset.loc[dataset['Country'] == sample_country], 'Broker'):
print(sample_country[0], "Broker")
else:
print('brokers aren’t settled with the appropriate brokers')
Edited for the case of more than one samples in sample_df
:
for i in range(len(sample_broker)):
if sample_broker[i].isin(dataset.loc[dataset['Country'] == sample_country[i]], 'Broker'):
print(sample_country[i], "Broker")
else:
print('brokers aren’t settled with the appropriate brokers')