数据帧内的熊猫计算

时间:2017-01-17 23:56:07

标签: python pandas

拥有一个简单的pandas数据框:

      period        count
       0            4000
       1            20000

如何使用pandas语法和此数据帧执行计算4000 /(4000 + 20000)?

1 个答案:

答案 0 :(得分:0)

您可以使用<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://openlayers.org/en/v3.20.1/css/ol.css" type="text/css"> <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x --> <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://openlayers.org/en/v3.20.1/build/ol.js"></script> </head> <body> <div id="map" class="map" tabindex="0"></div> <script> var map = new ol.Map({ layers: [ new ol.layer.Tile({ source: new ol.source.OSM() }) ], target: 'map', view: new ol.View({ center: [0, 0], zoom: 2 }) }); console.log("map layer is an instanceof ol.layer.tile? ", map.getLayers().getArray()[0] instanceof ol.layer.Tile) function cloneLayer() { map.getLayers().getArray().forEach(function(layer) { var copyLayer = jQuery.extend(true, {}, layer); console.log("CopyLayer is an instanceof ol.layer.tile? ", copyLayer instanceof ol.layer.Tile) console.log("CopyLayer is equal to mapLayer? ", map.getLayers().getArray()[0] == copyLayer) }); } cloneLayer() </script> </body> </html>方法进行求和,然后进行除法。

rolling