总结一只熊猫系列

时间:2017-11-30 19:32:01

标签: python pandas dataframe sum series

我有一个pandas Series对象,看起来像这样:

(Pdb) PiECoS  
t   sit    com      com_type  
1   South  Coal     Stock       2.0  
1   Mid    Solar    SupIm       4.0  
2   South  Coal     Stock       1.0  
2   Mid    Solar    SupIm       0.0  
                               ...
10  South  Coal     Stock       0.0
10  Mid    Solar    SupIm       0.0

Name: sub_commodity_source, Length: 300, dtype: float64

预期产出:

将所有t = 1加到10并将其加到t = 10

t   sit    com      com_type  
1   South  Coal     Stock       2.0  
1   Mid    Solar    SupIm       4.0  
2   South  Coal     Stock       1.0  
2   Mid    Solar    SupIm       0.0  
                               ...
10  South  Coal     Stock       3.0
10  Mid    Solar    SupIm       4.0

t   sit    com      com_type    
10  South  Coal     Stock       3.0
10  Mid    Solar    SupIm       4.0

1 个答案:

答案 0 :(得分:0)

如果我理解你的要求,你想要总结关于t指数的所有值:

function ti_pos_fun ()
    {
    var a = document.getElementById("jsel");
    if (a != null){
    a.id = "ti_pos";
     document.getElementById('ti_pos').innerHTML = 'hahahahaha';
     //$("#ti_pos").text('hahahaha');
    }else{
    var a = document.getElementById("ti_neg");
    a.id = "ti_pos";
     document.getElementById('ti_pos').innerHTML = 'hahahahaha';
     //$("#ti_pos").text('hahahaha');
    }
    }

    function ti_neg_fun ()
    {
    var a = document.getElementById("jsel");
    if(a != null){
    a.id = "ti_neg";
    //$("#ti_neg").text('angry');
    document.getElementById('ti_neg').innerHTML = 'angry';
    }else{
    var a = document.getElementById("ti_pos");
    a.id = "ti_neg";
    //$("#ti_neg").text('angry');
    document.getElementById('ti_neg').innerHTML = 'angry';
    }
    }