擅长:python、mysql、java
<p>您可以创建新的多重索引并分配给<code>columns</code>:</p>
<pre><code>df = pd.read_csv('mrh.csv', header=[0,1], na_values=[-1,''])
a = df.columns.get_level_values(level=0)
b = df.columns.get_level_values(level=1).str.replace('Un.*','')
df.columns = [a, b]
print (df)
Name Height Age
Metres
0 A NaN 25.0
1 B 95.0 NaN
</code></pre>
<p>或者:</p>
^{pr2}$