# Why can't i use an AND statement to filter out for Low Enrollment

Your Code:

``````low_enrollment = (combined["total_enrollment"] < 1000) & (combined["sat_score"] < 1000)
low_enrollment = combined.loc[low_enrollment,]
print(low_enrollment["SchoolName"])
``````

What I expected to happen: to be able to filter out for total enrolment below 1K and sat score below 1K

What actually happened: I get a different results from the answer. The answer Hint is
You may want to use two different statements to perform the filtration ā one to keep only those rows where `total_enrollment` is under `1000` , and the other to keep rows where `sat_score` is under `1000`

Other details: Why is that so? Trying to understand why i get different results in this case

1 Like

ā&ā - did you mean āandā? In python, ā&ā is a bitwise operator, āandā is the logical operator.

sorry, i mean &. is there a difference in outcomes for the 3 here
AND versus & versus performing in 2 different statements like the below?

``````low_enrollment = combined[combined["total_enrollment"] < 1000]
low_enrollment = low_enrollment[low_enrollment["sat_score"] < 1000]
``````

Hi,

not sure if the question still stands but hereās how I did it and it worked:

low_enrollment = combined[(combined[ātotal_enrollmentā] < 1000) & (combined[āsat_scoreā] < 1000)]

Hope this helps!
Ivelina

3 Likes

`low_enrollment=combined.loc[(combined["total_enrollment"]<1000)& (combined["sat_score"]<1000)]`

this code above worked perfectly for me.

I think your error might result from using the same variable name for the filter condition variable and the new_dataframe variable