0

I've a dataframe and I need to make filter based on two conditions: If first_name = 'Aleshia' OR if last_name = 'Andrade'

I was trying with the code below:

import pandas as pd

df = pd.read_csv('https://s3-eu-west-1.amazonaws.com/shanebucket/downloads/uk-500.csv')
data_new = df[df.first_name == 'Aleshia' or df.last_name  == 'Andrade']
print(data_new)

But I am getting the following error:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

What I am doing wrong?

2 Answers2

0
data_new = df[(df.first_name == 'Aleshia') | (df.last_name  == 'Andrade')]
Mayank Porwal
  • 33,470
  • 8
  • 37
  • 58
0
data_new = df.loc[(df.first_name == 'Aleshia') | (df.last_name  == 'Andrade'), :]
David Smolinski
  • 514
  • 3
  • 13