Great! Why don't we combine everything we've learned? It is pretty useful to combine the
loc function and filtering to get only a few columns from the rows that meet certain conditions. For example, we would like to see only the names of the hospitals that are located in Aberdeen and have overall rating greater than 4.
aberdeen_hospitals = hospitals['City'] == 'Aberdeen'
hospital_rating = hospitals['Hospital overall rating'] > 4
hospitals.loc[ aberdeen_hospitals & hospital_rating, 'Hospital Name']
Note that we used the
loc function and then provided our conditions in the same way as before. The only difference is that we also provided the name of the column we want to see after a comma.