Among 99 Iowa counties, only the following 10 counties have a population close to or more than 100 000. Filter and name the dataset, so you only have the data from the counties: Polk, Linn, Scott, Johnson, Black Hawk, Woodbury, Dubuque, Story, Dallas, and Pottawattamie. Resent the index of the filtered data set. Check to make sure (using Python) you have the correct counties.
I'm not really sure how to select multiple county names all at once.
I tried to use the ils[(ils.County == "Polk") & (ils.County == "Linn") & (ils.County == "Scott") & (ils.County == "Johnson") & (ils.County == "Black Hawk") & (ils.County == "Woodbury") & (ils.County == "Dubuque") & (ils.County == "Story") & (ils.County =="Dallas") & (ils.County == "Pottawattamie")]
enter image description here this is all I'm getting.
CodePudding user response:
You can use isin
. https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.isin.html
ils[ils['County'].isin(["Polk", "Linn", "Scott"])]
CodePudding user response:
Apparently you should use |
instead of &
, cause a country name should be either "Polk" or "Linn", not both.