Python Forum
Rolling Sum by Facility - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Rolling Sum by Facility (/thread-30793.html)



Rolling Sum by Facility - dsparker78 - Nov-05-2020

I'm looking to create a rolling 12 average for a dataset. The data set has columns for MONTH, Facility, Patient Days.

I want to create a rolling 12 for Patient days but group by Facility.

So for example, Facility X has monthly data with patient days, I want to calculate the rolling for 12 months by Facility X but not Facility Y which needs its own rolling 12.

example of Dataset

MONTH Facility PatientDays
7/1/19 X 100
8/1/19 X 200
9/1/19 X 300
7/1/19 Y 200
8/1/19 Y 100
9/1/19 Y 500


RE: Rolling Sum by Facility - deanhystad - Nov-06-2020

This looks like a pretty easy problem. Pandas is designed to do this kind of work. What have you got so far?