<p>这里有一个<a href="https://pandas.pydata.org/pandas-docs/stable/index.html" rel="nofollow noreferrer">pandas</a>解决方案,正如您提到的,尝试熊猫失败了。您可以将<a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_dict.html" rel="nofollow noreferrer">^{<cd1>}</a>与<code>orient=index</code>一起使用</p>
<pre><code>import pandas as pd
df = pd.DataFrame.from_dict(student, orient='index').reset_index(drop=True)
</code></pre>
<p>你得到</p>
<pre><code> Name Grade Math English Physics Chemistry
0 Eddy 1 78 65 89 80
1 Jim 2 89 65 87 76
2 Jane 3 87 97 75 64
</code></pre>
<h2>对于<code>markdown</code>表</h2>
<ul>
<li>使用<a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_markdown.html" rel="nofollow noreferrer">^{<cd4>}</a></li>
</ul>
<pre><code>print(df.to_markdown(index=False))
| Name | Grade | Math | English | Physics | Chemistry |
|:-------|--------:|-------:|----------:|----------:|------------:|
| Eddy | 1 | 78 | 65 | 89 | 80 |
| Jim | 2 | 89 | 65 | 87 | 76 |
| Jane | 3 | 87 | 97 | 75 | 64 |
</code></pre>
<ul>
<li>与其他实现相比,pandas的优势在于,数据现在的格式便于分析和绘图</李>
</ul>
<pre class="lang-py prettyprint-override"><code>import matplotlib.pyplot as plt
df.plot.barh(x='Name', y=['Math', 'English', 'Physics', 'Chemistry'], figsize=(6, 8))
plt.xlabel('Score')
plt.legend(title='Subject', bbox_to_anchor=(1.05, 1), loc='upper left')
</code></pre>
<p><a href="https://i.stack.imgur.com/cyRyc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cyRyc.png" alt="enter image description here"/></a></p>