Last active
April 5, 2021 20:59
-
-
Save samirsaci/e277740335a6d9a20b098332e84daa9b to your computer and use it in GitHub Desktop.
Prep data pulp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| from pulp import * # pip install pulp | |
| import matplotlib.pyplot as plt | |
| from itertools import chain, repeat | |
| def ncycles(iterable, n): | |
| "Returns the sequence elements n times" | |
| return chain.from_iterable(repeat(tuple(iterable), n)) | |
| # Staff needs per Day | |
| n_staff = [31, 45, 40, 40, 48, 30, 25] | |
| # Days of the week | |
| jours = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] | |
| # Create circular list of days | |
| n_days = [i for i in range(7)] | |
| n_days_c = list(ncycles(n_days, 3)) | |
| # Working days | |
| list_in = [[n_days_c[j] for j in range(i , i + 5)] for i in n_days_c] | |
| # Workers off by shift for each day | |
| list_excl = [[n_days_c[j] for j in range(i + 1, i + 3)] for i in n_days_c] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment