Python Forum

Full Version: "SUMIF" type query in Python (help required)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!

Hello all, great to be here!

I'm new to Python and have hit a brick wall with the following problem.

I have two dataframes and I would like to do a "sumif" type calculation to produce a new dataframe. I cannot figure it out.

The two df's are as so:
df1: "Customer ID", "Contract Name", "Date", "Amount"
df2: "Customer ID", "Contract Name", "Date"

I need to create a dataframe (df3) with the "Customer ID" and "Contract Title" with a sum of the Amount based on the following criteria:

Cust. ID and Contract Name Match and Date in df1 is AFTER date in df2.

I have concatenated the dfs but I am stuck with where to go next and I am struggling with the syntax of the criteria I need.

I would greatly appreciate anyone's help on this. I have a feeling it'll be obvious when someone explains how to do it, but I am frustrated I can't crack it.