Skip to content
Advertisement

Python – Sum values for all dates prior to a specific date

I currently have two dataFrames that look like this:

JavaScript

Df4:

JavaScript

I am trying to add a new column to Df3, which is the sum of all Sales (SalesAmt) where the invoicing date (InvoiceDt) is prior to the date column in Df3.

JavaScript

I get the following error in this case:

JavaScript

Any idea how to fix this? Or a more efficient way to obtain the wanted result?

Thanks a lot,

Advertisement

Answer

EDIT: I misunderstood your problem definition earlier. Now corrected it:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement