1. <small id='L6H8O'></small><noframes id='L6H8O'>

      • <bdo id='L6H8O'></bdo><ul id='L6H8O'></ul>

      <tfoot id='L6H8O'></tfoot>
    2. <legend id='L6H8O'><style id='L6H8O'><dir id='L6H8O'><q id='L6H8O'></q></dir></style></legend>
    3. <i id='L6H8O'><tr id='L6H8O'><dt id='L6H8O'><q id='L6H8O'><span id='L6H8O'><b id='L6H8O'><form id='L6H8O'><ins id='L6H8O'></ins><ul id='L6H8O'></ul><sub id='L6H8O'></sub></form><legend id='L6H8O'></legend><bdo id='L6H8O'><pre id='L6H8O'><center id='L6H8O'></center></pre></bdo></b><th id='L6H8O'></th></span></q></dt></tr></i><div id='L6H8O'><tfoot id='L6H8O'></tfoot><dl id='L6H8O'><fieldset id='L6H8O'></fieldset></dl></div>

      Panda 数据透视表边距仅在行上

      时间:2023-10-19

          <tbody id='DF0J7'></tbody>

      1. <i id='DF0J7'><tr id='DF0J7'><dt id='DF0J7'><q id='DF0J7'><span id='DF0J7'><b id='DF0J7'><form id='DF0J7'><ins id='DF0J7'></ins><ul id='DF0J7'></ul><sub id='DF0J7'></sub></form><legend id='DF0J7'></legend><bdo id='DF0J7'><pre id='DF0J7'><center id='DF0J7'></center></pre></bdo></b><th id='DF0J7'></th></span></q></dt></tr></i><div id='DF0J7'><tfoot id='DF0J7'></tfoot><dl id='DF0J7'><fieldset id='DF0J7'></fieldset></dl></div>
      2. <legend id='DF0J7'><style id='DF0J7'><dir id='DF0J7'><q id='DF0J7'></q></dir></style></legend>

        • <tfoot id='DF0J7'></tfoot>

            <small id='DF0J7'></small><noframes id='DF0J7'>

              <bdo id='DF0J7'></bdo><ul id='DF0J7'></ul>

              1. 本文介绍了Panda 数据透视表边距仅在行上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                有人知道如何在熊猫数据透视表上只在行上做边距吗?当前设置将计算行和列边距谢谢!

                Anyone knows how to do margins on panda pivot table only on row? current setting will calculate both row and column margin Thanks !

                推荐答案

                您可以通过使用 DataFrame.iloc:

                You can remove them by indexing with DataFrame.iloc:

                df = pd.DataFrame({
                    'A': ['a','b','a','a'],
                    'B': ['a','d','d','b']
                })
                
                df = pd.crosstab(df['A'], df['B'], margins=True)
                print (df)
                B    a  b  d  All
                A                
                a    1  1  1    3
                b    0  0  1    1
                All  1  1  2    4
                
                df1 = df.iloc[:, :-1]
                print (df1)
                B    a  b  d
                A           
                a    1  1  1
                b    0  0  1
                All  1  1  2
                
                df2 = df.iloc[:-1]
                print (df2)
                B  a  b  d  All
                A              
                a  1  1  1    3
                b  0  0  1    1
                

                这篇关于Panda 数据透视表边距仅在行上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何在 Pandas 中使用总计(边距)创建数据透视? 下一篇:如何根据python中的通用ID值将2列的垂直pandas表转换为水平表

                相关文章

              2. <small id='dPAwL'></small><noframes id='dPAwL'>

                <legend id='dPAwL'><style id='dPAwL'><dir id='dPAwL'><q id='dPAwL'></q></dir></style></legend>
                    <bdo id='dPAwL'></bdo><ul id='dPAwL'></ul>
                  <i id='dPAwL'><tr id='dPAwL'><dt id='dPAwL'><q id='dPAwL'><span id='dPAwL'><b id='dPAwL'><form id='dPAwL'><ins id='dPAwL'></ins><ul id='dPAwL'></ul><sub id='dPAwL'></sub></form><legend id='dPAwL'></legend><bdo id='dPAwL'><pre id='dPAwL'><center id='dPAwL'></center></pre></bdo></b><th id='dPAwL'></th></span></q></dt></tr></i><div id='dPAwL'><tfoot id='dPAwL'></tfoot><dl id='dPAwL'><fieldset id='dPAwL'></fieldset></dl></div>
                    <tfoot id='dPAwL'></tfoot>