1

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.

vinzee
  • 17,022
  • 14
  • 42
  • 60
snow_fall
  • 205
  • 1
  • 4
  • 13

0 Answers0