title: Using apply method on pandas series getting TypeError 'Series' objects are mutable, thus they cannot be hashed
body: <p>I have two data frames <code>D1</code> and <code>D2</code>. What I want to achieve is for any column pairs in <code>D1</code> and <code>D2</code> which are non-int and non-float type, I want to compute a distance metric using the formula </p>
  
  <pre><code> |A intersect B|/ |A union B|
  </code></pre>
  
  <p>I first defined a function</p>
  
  <pre><code>def jaccard_d(series1, series2):
      if (series1.dtype is not (pd.np.dtype(int) or pd.np.dtype(float))) and     (series2.dtype is not (pd.np.dtype(int) or pd.np.dtype(float))):
          series1 = series1.drop_duplicates()
          series2 = series2.drop_duplicates()
          return len(set(series1).intersection(set(series2)))     /len(set(series1).union(set(series2)))
      else:
          return np.nan
  </code></pre>
  
  <p>Then what I did is to first loop over all columns in <code>D1</code>, then for each fixed column in <code>D1</code>, I use <code>apply</code> on my <code>jaccard_d</code> function. I try to avoid writing 2 layer loops. May be there is a better way without wrting any loops?</p>
  
  <pre><code>DC = dict.fromkeys(list(D1.columns))
  INN = list(D2.columns)
  for col in D1:
      DC[col] = dict(zip(INN, D2.apply(jaccard_d,D1[col])))
  </code></pre>
  
  <p>First, I am not sure whether I use the <code>apply</code> function correctly, i.e., my <code>jaccard_d</code> function takes 2 series as input, but here for each iteration, I have <code>D1[col]</code> as one series, and I want to use <code>apply</code> to apply <code>D1[col]</code> to all columns of <code>D2</code></p>
  
  <p>Second, I get this error "'Series' objects are mutable, thus they cannot be hashed", which I don't quite understand. Any comments are appreciated.</p>
  
  <p>I tried to just write a 2-layer loop and use my function <code>jaccard_d</code> to do that. It works. But I want to write more efficient code.</p>