This is the repository for inventory simulation module for Safe Decor. It includes simulation and order recommendation functionality
pip install invsim
Clip_date returns first non zero date if there are at least 30 elements, if not just returns the first date
Case1: there are more than 30 elements
ndays=40
leading_zero_days=5
dates=pd.date_range(start='2022-01-01', periods=ndays, freq='D')
values=[0]*leading_zero_days+[10]*(ndays-leading_zero_days)
df=pd.DataFrame({'date':dates, 'qty': values})
df['date']=df.date.apply(lambda x: x.date())
display(df.T)
print("clip date =", clip_date(df))
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
</style>
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
date | 2022-01-01 | 2022-01-02 | 2022-01-03 | 2022-01-04 | 2022-01-05 | 2022-01-06 | 2022-01-07 | 2022-01-08 | 2022-01-09 | 2022-01-10 | ... | 2022-01-31 | 2022-02-01 | 2022-02-02 | 2022-02-03 | 2022-02-04 | 2022-02-05 | 2022-02-06 | 2022-02-07 | 2022-02-08 | 2022-02-09 |
qty | 0 | 0 | 0 | 0 | 0 | 10 | 10 | 10 | 10 | 10 | ... | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 |
2 rows × 40 columns
clip date = 2022-01-06
Case2: There are less than 30 elements
ndays=29
leading_zero_days=5
dates=pd.date_range(start='2022-01-01', periods=ndays, freq='D')
values=[0]*leading_zero_days+[10]*(ndays-leading_zero_days)
df=pd.DataFrame({'date':dates, 'qty': values})
df['date']=df.date.apply(lambda x: x.date())
display(df.T)
print("clip date =", clip_date(df))
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
</style>
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
date | 2022-01-01 | 2022-01-02 | 2022-01-03 | 2022-01-04 | 2022-01-05 | 2022-01-06 | 2022-01-07 | 2022-01-08 | 2022-01-09 | 2022-01-10 | ... | 2022-01-20 | 2022-01-21 | 2022-01-22 | 2022-01-23 | 2022-01-24 | 2022-01-25 | 2022-01-26 | 2022-01-27 | 2022-01-28 | 2022-01-29 |
qty | 0 | 0 | 0 | 0 | 0 | 10 | 10 | 10 | 10 | 10 | ... | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 |
2 rows × 29 columns
clip date = 2022-01-01