Screen Link: https://app.dataquest.io/m/138/data-cleaning-walkthrough%3A-analyzing-and-visualizing-the-data/6/exploring-schools-with-low-sat-scores-and-enrollment
low_enrollment = (combined["total_enrollment"] < 1000) & (combined["sat_score"] < 1000)
low_enrollment = combined.loc[low_enrollment,]
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
Other details: Why is that so? Trying to understand why i get different results in this case
“&” - 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]
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!
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