pan class="sd">&quot;&quot;&quot;</span>

<span class="sd">    Args:</span>
<span class="sd">        df:</span>
<span class="sd">        optimal:</span>
<span class="sd">        dist_method:</span>
<span class="sd">        cluster_method:</span>

<span class="sd">    Returns:</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">dist_mat</span> <span class="o">=</span> <span class="n">pdist</span><span class="p">(</span><span class="n">df</span><span class="p">,</span> <span class="n">m