擅长:python、mysql、java
<p>您只需<code>stack</code>列(将其移动到索引)并使用drop=True调用<code>reset_index</code>,或者可以使用<code>reset_index()</code>作为起点编写<code>reset_columns()</code>方法(请参见框架py#L2940)在</p>
<pre><code>df.query('some query')
.apply(cool_func)
.stack(level='unwanted_col_level_name')
.reset_index('unwanted_col_level_name',drop=True)
.apply(another_cool_func)
</code></pre>
<hr/>
<p>替代方案:猴头贴解决方案</p>
^{pr2}$