low_enrollment = df[ df['total_enrollment'] < 1000 ]
low_enrollment = df[df['sat_score'] < 1000]
How can i combine them in one line? This does not work.
low_enrollment = df[ df['total_enrollment'] < 1000 and df['sat_score'] < 1000]
low_enrollment = df[ df['total_enrollment'] < 1000 ]
low_enrollment = df[df['sat_score'] < 1000]
How can i combine them in one line? This does not work.
low_enrollment = df[ df['total_enrollment'] < 1000 and df['sat_score'] < 1000]
You should be using the &
operator for logical and, not the Python and
:
low_enrollment = df[(df['total_enrollment'] < 1000) & (df['sat_score'] < 1000)]