Python Forum
"SUMIF" type query in Python (help required)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"SUMIF" type query in Python (help required)
#1
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  list the files using query in python arjunaram 0 682 Mar-28-2023, 02:39 PM
Last Post: arjunaram
  python sql query single quote in a string mg24 1 1,083 Nov-18-2022, 08:01 PM
Last Post: deanhystad
  MSSQL query not working in Python kat35601 0 928 Apr-12-2022, 06:44 PM
Last Post: kat35601
  Error using mariadb select query with form in python? shams 2 2,024 Jul-29-2021, 12:30 PM
Last Post: shams
  python 3: TypeError: a bytes-like object is required, not 'str' wardancer84 3 6,525 Jul-09-2021, 05:55 PM
Last Post: deanhystad
  Python mysql query help please tduckman 4 4,331 Mar-13-2020, 03:42 PM
Last Post: Marbelous
  Type hinting - return type based on parameter micseydel 2 2,511 Jan-14-2020, 01:20 AM
Last Post: micseydel
  Type error: dump() missing 1 required positional argument: fp jaycuff13 2 21,963 Jul-13-2019, 10:21 AM
Last Post: jaycuff13
  Installing Python and pointing it to required libraries hooiberg 2 4,327 May-13-2019, 05:55 PM
Last Post: ebolisa
  SQLite Query in Python rowyourboat 2 2,823 Apr-26-2019, 02:24 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020