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