Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
Same month cumulative sum

What is the best way to have a cumulative total of data values when the "month" in the date column is the same? Can this be done using resample() + sum()?

I'm thinking I can probably use something off the shelf in python instead of creating a custom function.

Want:

Input:
             Value 
Date                   
2015-01-01   1 
2014-01-01   2
2017-03-01   3 
2015-04-01   4 
2016-03-01   5 

Output:
             Value 
Month                   
January      3 
March        8
April        4 

Thanks!

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I would prefer a more straightforward approach with index.month_name:

df.groupby(df.index.month_name()).sum()
over 4 years ago · Santiago Trujillo Report

0

In your case , this can help you out

out = df.groupby(df.index.strftime('%b')).sum()

output:

      Value
Date       
Apr       4
Jan       3
Mar       8
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!