简体   繁体   English

基于两列求和列

[英]Sum column based on two columns

I want to create a new column that will sum the overall Value(£) for each port for the Length Groups "10m&Under" and "Over10m"我想创建一个新列,将对长度组“10m&Under”和“Over10m”的每个端口的总价值 (£) 求和

在此处输入图像描述

Try something like:尝试类似的东西:

df[df['Length Group'].isin(["10m&Under", "Over10m"])].pivot_table(values='Value(£)', index='Port of Landing', aggfunc='sum')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 根据两个不同的列对一列求和 - sum a column based on two different columns Python Pandas:根据另外两列的值查找列的总和 - Python Pandas: Find Sum of Column Based on Value of Two other Columns 如何根据另一个列值对两个数据框列求和 - How to sum two dataframe columns based on another column value 根据 dataframe 中两列之间的差异对字典的值求和,并将第一列除以二 - Python - Sum the value of a dictionary based on the difference between two columns in a dataframe and divide the first column by two - Python 基于 Project 和 ID 两列的 SUM - SUM based on two columns for Project and ID 基于两个单独列中的日期范围求和 - Sum based on date range in two separate columns 如何根据来自其他两列的值的分组总和创建新的值列? - How can I create a new column of values based on the grouped sum of values from two other columns? 如何创建两个具有基于列值的累加总和并具有分组依据的列 - How to create two columns having cumulative sum based on a column value and having group by 如何使用 Pandas 根据另一列的值将两列相加 - How to sum two columns together based on another column's value using Pandas 使用 Pandas groupby 对基于另一个分类列的两个分类列应用 sum & count - using pandas groupby apply sum & count for two categorical columns based on another categorical column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM