'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"

enter image description here



Solution 1:[1]

Try something like:

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1