larray.Array.percent

Array.percent(*axes) Array[source]

Return an array with values given as percent of the total of all values along given axes.

Parameters
*axes
Returns
Array

array / array.sum(axes) * 100

Examples

>>> nat = Axis('nat=BE,FO')
>>> sex = Axis('sex=M,F')
>>> a = Array([[4, 6], [2, 8]], [nat, sex])
>>> a
nat\sex  M  F
     BE  4  6
     FO  2  8
>>> a.percent()
nat\sex     M     F
     BE  20.0  30.0
     FO  10.0  40.0
>>> a.percent('sex')
nat\sex     M     F
     BE  40.0  60.0
     FO  20.0  80.0