<p>我有一个名为<strong>mrh.csv公司</strong>前两行表示标题:</p>
<pre><code>Name,Height,Age
"",Metres,""
A,-1,25
B,95,-1
</code></pre>
<p>我使用以下代码将其读入DataFrame:</p>
^{pr2}$
<p>这将生成包含以下内容的数据帧:</p>
<pre><code> Name Height Age
Unnamed: 0_level_1 Metres Unnamed: 2_level_1
0 A NaN 25.0
1 B 95.0 NaN
</code></pre>
<p>使用read_csv的na_values参数,我可以在文件中标记为-1的缺失值,但当标记为“”(我也尝试了-1)时,丢失的标题行值将显示为<strong>未命名:x_level_y</strong>(如果改为使用-1)。在</p>
<p>有没有办法不显示丢失的值-删除未命名的:x\u level_y</strong>或用有意义的值替换它?在</p>
<p>期望输出1:</p>
<pre><code> Name Height Age
Metres
0 A NaN 25.0
1 B 95.0 NaN
</code></pre>
<p>期望输出2:</p>
<pre><code> Name Height Age
- Metres -
0 A NaN 25.0
1 B 95.0 NaN
</code></pre>