A列が1, B列が2 である行のC列の合計値
test.py
import pandas as pd
df1 = pd.DataFrame([[1, 1, 12],
[1, 2, 11],
[1, 1, 18],
[2, 2, 19],
[2, 1, 10],
[2, 2, 14],
[1, 1, 15],
[1, 2, 17],
[1, 1, 19]],
columns=['A', 'B', 'C'])
sum_of_c = df1.loc[(df1['A'] == 1) & (df1['B'] == 2), 'C'].sum()
print('sum={}'.format(sum_of_c))
出力結果
sum=28