如何根据条件添加列?

2024-10-06 07:51:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我有这个

    Area    Element Code    Element Code    Item YCode  Year    Value   Type
39  India   5312    Area  harvested 125 Cassava  2000   2000    27179.0 food
40  India   5312    Area  harvested 125 Cassava  2001   2001    27794.0 food
41  India   5312    Area  harvested 125 Cassava  2002   2002    21408.0 food
42  India   5312    Area  harvested 125 Cassava  2003   2003    36061.0 food
43  India   5312    Area  harvested 125 Cassava  2004   2004    59585.0 food
... ... ... ... ... ... ... ... ... ...
1071  India 5510    Production  567 Watermelons 2014    2014    229267.0 food
1072  India 5510    Production  567 Watermelons 2015    2015    270686.0 food
1073  India 5510    Production  567 Watermelons 2016    2016    258691.0 food
1074  India 5510    Production  567 Watermelons 2017    2017    243203.0 food
1075  India 5510    Production  567 Watermelons 2018    2018    239896.0 food

我想得到一个新的列,包含每个项目的总和,即木薯,西瓜在相应的年份。 i、 e如果年份为2001年,则为每种作物的价值总和 ,然后是明年

如果有人给我一个主意,我将不胜感激


Tags: foodvaluecodeareaelementitemyearproduction