-
-
Save sannykhan3777/ad3641c8e18b18786a950fa0be308e0d to your computer and use it in GitHub Desktop.
Subsetting data based on a categorical variable often involves using the "or" operator (|) to select rows from multiple categories. This can get tedious when you want all states in one of three different regions, for example. Instead, use the .isin() method, which will allow you to tackle this problem by writing one condition instead of three se…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Subset for rows in South Atlantic or Mid-Atlantic regions | |
south_mid_atlantic = homelessness [(homelessness["region"]=="South Atlantic") | (homelessness["region"]=="Mid-Atlantic")] | |
# See the result | |
print(south_mid_atlantic) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment