0

I'm trying to remove rows from a dataframe if a particular column value does not appear in a previously defined dictionary

dff= dff[dff['network'] in net_dic]

Each value of 'network' is a string. and net_dic looks like this:

{ 'abc' : 1
  'def' : 2
. 
. 
.}

It errors:

TypeError: 'Series' objects are mutable, thus they cannot be hashed
Dumbo
  • 1,068
  • 2
  • 12
  • 21

1 Answers1

0

Ah this works:

dff= dff[dff['network'].isin(net_dic.keys())]
Dumbo
  • 1,068
  • 2
  • 12
  • 21