擅长:python、mysql、java
<p>您可以使用<a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.dot.html" rel="nofollow noreferrer">^{<cd1>}</a>及其转置:</p>
<pre><code>In [11]: df.T.dot(df)
Out[11]:
dan ste bob
dan 9 2 4
ste 2 6 2
bob 4 2 9
</code></pre>