pandas sum values in a column based on condition code example Example: pandas dataframe sum with condition subset_df = df[df["A"] > 3] column_sum = subset_df.sum()