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 数据透视表边距仅在行上

      Panda pivot table margins only on row(Panda 数据透视表边距仅在行上)

          <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 数据透视表边距仅在行上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Running .jl file from R or Python(从 R 或 Python 运行 .jl 文件)
                Running Julia .jl file in python(在 python 中运行 Julia .jl 文件)
                Using PIP in a Azure WebApp(在 Azure WebApp 中使用 PIP)
                How to run python3.7 based flask web api on azure(如何在 azure 上运行基于 python3.7 的烧瓶 web api)
                Azure Python Web App Internal Server Error(Azure Python Web 应用程序内部服务器错误)
                Run python dlib library on azure app service(在 azure app 服务上运行 python dlib 库)

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

                    <tbody id='dPAwL'></tbody>
                  <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>