2

I have a Pandas Dataframe and there are some columns that I want to keep in terms of location and others I do not.

I know that when selecting a specific value in a column to get a row I can use:

x = df[df['location']=='Aberdeen']

However, how can I do it for many locations without having to do them individually and then concatenate?

This is what Ive tried:

x = df[[df['location']=='Aberdeen' & 'Glasgow' & 'London']]

But I am receiving a:

TypeError: 'Series' objects are mutable, thus they cannot be hashed

I know there must be a super simple solution to this but I haven't figured it out, please help.

vvvvv
  • 25,404
  • 19
  • 49
  • 81
snow_fall
  • 225
  • 1
  • 5
  • 13

0 Answers0