• <small id='Up6eu'></small><noframes id='Up6eu'>

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

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

      1. 计算DataFrame上的百分比

        时间:2024-08-21
            <tbody id='VeSG3'></tbody>

            • <bdo id='VeSG3'></bdo><ul id='VeSG3'></ul>
            • <legend id='VeSG3'><style id='VeSG3'><dir id='VeSG3'><q id='VeSG3'></q></dir></style></legend>

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

              1. <tfoot id='VeSG3'></tfoot>
                  <i id='VeSG3'><tr id='VeSG3'><dt id='VeSG3'><q id='VeSG3'><span id='VeSG3'><b id='VeSG3'><form id='VeSG3'><ins id='VeSG3'></ins><ul id='VeSG3'></ul><sub id='VeSG3'></sub></form><legend id='VeSG3'></legend><bdo id='VeSG3'><pre id='VeSG3'><center id='VeSG3'></center></pre></bdo></b><th id='VeSG3'></th></span></q></dt></tr></i><div id='VeSG3'><tfoot id='VeSG3'></tfoot><dl id='VeSG3'><fieldset id='VeSG3'></fieldset></dl></div>
                • 本文介绍了计算DataFrame上的百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试计算以下数据帧的每个犯罪的百分比:

                          Violent     Murder      Larceny_Theft   Vehicle_Theft
                  Year
                  1960    288460      3095700     1855400         328200
                  1961    289390      3198600     1913000         336000
                  1962    301510      3450700     2089600         366800
                  1963    316970      3792500     2297800         408300
                  1964    364220      4200400     2514400         472800
                  
                  所以我应该先计算每年的犯罪总数,然后用它来计算每种犯罪的百分比。我正在尝试以下操作:

                  > perc = (crime *100) / crime.sum(axis=1)
                  

                  有什么想法吗? 谢谢!

                  推荐答案

                  使用函数DataFrame.divFOR除以Series

                  perc = crime.mul(100).div(crime.sum(axis=1), axis=0)
                  #perc = (crime *100).div(crime.sum(axis=1), axis=0)
                  print (perc)
                         Violent     Murder  Larceny_Theft  Vehicle_Theft
                  Year                                                   
                  1960  5.180899  55.600457      33.323994       5.894651
                  1961  5.044283  55.753976      33.345012       5.856730
                  1962  4.856320  55.579268      33.656487       5.907925
                  1963  4.650675  55.644649      33.713981       5.990695
                  1964  4.822943  55.621029      33.295285       6.260742
                  

                  这篇关于计算DataFrame上的百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何根据两个不同列的日期获取交叉连接表的唯一记录? 下一篇:数据帧中从第一行开始的间隔[python 3.6.0]

                  相关文章

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

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

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

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