I've been trying to find a solution to this problem for days, to no avail. Our warehouse asked for a way to calculate how many days it takes to process the incoming items, according to our forecast.
Table:
Raw data: pd.DataFrame({'daily capacity': {'May 11': 27500, 'May 12': 27500, 'May 13': 0, 'May 14': 0, 'May 15': 0, 'May 16': 0, 'May 17': 27500, 'May 18': 27500, 'May 19': 27500}, 'forecast_units': {'May 11': 18007, 'May 12': 19305, 'May 13': 19122, 'May 14': 17292, 'May 15': 19592, 'May 16': 23393, 'May 17': 19000, 'May 18': 18539, 'May 19': 18531}, 'backlog': {'May 11': 0, 'May 12': 0, 'May 13': -19122, 'May 14': -36414, 'May 15': -56006, 'May 16': -79399, 'May 17': -70899, 'May 18': -61938, 'May 19': -52969}})
Problem: How to calculate, for each date, how many days it will take for the warehouse to process all units arrived that day. Each date the warehouse has different processing capacity, which must be taken into account.
Example: "The warehouse will take 3.6 days to process all units arrived on May 16".
Output: a column with the # of processing days for each date
What I've done so far: I tried with .cumsum(), while loops and creating some definition, but couldn't find a way that works.
Raw data:
Do you have any ideas or suggested solutions? Thanks :-)
EDIT:
Temporary solution I've found, let me know if it's correct:
dad.rename({'index':'dates'},axis=1,inplace=True)
def days_pr(bk,ind):
temp = dad[ind:].copy()
temp['cum cap'] = temp['daily capacity'].cumsum()
i = ind
cum_cp = temp['cum cap'][i]
while cum_cp < abs(bk) and ind<7:
i+=1
cum_cp = temp['cum cap'][i]
else:
return (i-ind)
dad['days'] = [days_pr(bk,ind) for bk,ind in zip(dad['backlog'],dad.index)]
dad
Controller Advice bean not instantiated at proper order in Spring Boot 2.4
What should I enter to the connection string to connect my NodeJS application to a MongoDB server?
Unable to use Computed Property Values with Dots - Unable to Set as String - JS
I have developed a notification that is sent every time a BroadcastReceiver is woken up by an AlarmMaganerWhen the receiver shows the notification it also takes care of activating the next notification
Want to improve this question? Update the question so it focuses on one problem only by editing this post
Helo! I am a beginner in programming and if anyone can help me change a code snippet I would appreciate itI have a scheduling system with time slots, where the slots are generated from variables with the start date until the end date