title: calculate distance matrix with mixed categorical and numerics
body: <p>I have a data frame with a mixture of numeric (15 fields) and categorical (5 fields) data.</p>
  
  <p>I can create a complete distance matrix of the numeric fields following <a href="https://stackoverflow.com/questions/57729146/create-distance-matrix-using-own-calculation-pandas">create distance matrix using own calculation pandas</a></p>
  
  <p>I want to include the categorical fields as well.</p>
  
  <p>Using as template:</p>
  
  <pre><code>import scipy
  from scipy.spatial import distance_matrix
  from scipy.spatial.distance import squareform
  from scipy.spatial.distance import pdist
  df2=pd.DataFrame({'col1':[1,2,3,4],'col2':[5,6,7,8],'col3':['cat','cat','dog','bird']})
  df2
  pd.DataFrame(squareform(pdist(df2.values, lambda u, v: np.sqrt((w*(u-v)**2).sum()))), index=df2.index, columns=df2.index)
  </code></pre>
  
  <p>in the squareform calculation, I would like to include the test <code>np.where(u[2]==v[2], 0, 10)</code> (as well as with the other categorical columns)</p>
  
  <p>Hpw do I modify the lambda function to carry out this test as well</p>
  
  <p>Here, the distance between [0,1]</p>
  
  <pre><code>= sqrt((2-1)^2 + (6-5)^2 + (cat - cat)^2)
  = sqrt(1 + 1 + 0)
  </code></pre>
  
  <p>and the distance between [0,2]</p>
  
  <pre><code>= sqrt((3-1)^2 + (7-5)^2 + (dog - cat)^2)
  = sqrt(4 + 4 + 100)
  </code></pre>
  
  <p>etc.</p>
  
  <p>Can anyone suggest how I can implement this algorithm?</p>