Business days (workdays) between two date, like `NetworkDays` function used on spreadsheets and more.
Project description
some statistics …
Pypi Version |
Doc Status |
Coverage |
Downloads |
---|---|---|---|
Business days calendar.
JobSchedule on business days.
- Networkdays:
Return working days between two dates exclude weekends and holidays.
just like spreadsheets networdays function
exclude Holidays
Exclude “days off” per week.
- Job schedule:
Calculate the period for a given job hours, based on Networdays.
Installation
python-networkdays can be installed from PyPI using pip
pip install python-networkdays
Page on Pypi: https://pypi.org/project/python-networkdays/
There is no dependencies.
Features
Return a list of business days between 2 dates.
Exclude weekends by default
Custom “days off” may be informed as list like {1,2,3,4,5,6,7}, where 1 is Monday default is {6,7} = (Sat, Sun).
How many business days between two dates.
How many days off, including holidays and weekends.
Return a list of business days for a given number of hours
Return a list of Years, months or weeks for a given number of hours
No Pandas or NumPy dependencies
Examples
Class Networkdays.networkdays
List business days, weekends and Holidays
In [1]: from networkdays import networkdays
In [2]: import datetime
In [3]: HOLIDAYS = { datetime.date(2020, 12, 25) } # define a Holidays list
# initiate class::`networkdays.Networkdays`
In [4]: days = networkdays.Networkdays(
datetime.date(2020, 12, 15), # start date
datetime.date(2020, 12, 31), # end date
HOLIDAYS # list of Holidays
)
In [5]: days.networkdays() # return a list os workdays
Out[5]:
[datetime.date(2020, 12, 15),
datetime.date(2020, 12, 16),
datetime.date(2020, 12, 17),
datetime.date(2020, 12, 18),
datetime.date(2020, 12, 21),
datetime.date(2020, 12, 22),
datetime.date(2020, 12, 23),
datetime.date(2020, 12, 24),
datetime.date(2020, 12, 28),
datetime.date(2020, 12, 29),
datetime.date(2020, 12, 30),
datetime.date(2020, 12, 31)]
In [6]: days.weekends() # list os Weekends (default = Saturday ans Sunday)
Out[6]:
[datetime.date(2020, 12, 19),
datetime.date(2020, 12, 20),
datetime.date(2020, 12, 26),
datetime.date(2020, 12, 27)]
In [7]: days.holidays()
Out[7]: [datetime.date(2020, 12, 25)] # list of holidays
class Networkdays.jobschedule
>>> from networkdays import networkdays
>>> import datetime
>>> # Distribute the 600 hrs of effort, starting on december 1, 2020 working 8hrs per day.
>>> jobschedule = networkdays.JobSchedule(600, 8, datetime.date(2020, 12, 1), networkdays=None)
>>> job_dates = jobschedule.job_workdays()
>>> jobschedule.bussines_days
54
>>> jobschedule.total_days
datetime.timedelta(days=73)
>>> jobschedule.prj_starts
'12/01/20'
>>> jobschedule.prj_ends
'02/12/21'
>>> list(jobschedule.years())
[2020, 2021]
>>> list(jobschedule.months())
[12, 1, 2]
>>> list(jobschedule.weeks()) # ISO
[49, 50, 51, 52, 53, 1, 2, 3, 4, 5, 6]
>>> f'days: {list(jobschedule.days())[:2]} ... {list(jobschedule.days())[-2:]}'
'days: [datetime.date(2020, 12, 1), datetime.date(2020, 12, 2)] ... [datetime.date(2021, 2, 11), datetime.date(2021, 2, 12)]'
Other similar projects
When I start to code, I did check for some similar projects.
I knew about python-dateutil, a great project I use for years… I’d like something more straightforward or simpler.
After to publish the python-networkdays on PyPi I found some others 8(
workdays : A 5 years old project, looks the same as networkdays
timeboard : A more complex but powerful project
python-dateutil is great, powerful but even more complex.
python-bizdays : Quick simple and direct …
I will try to keep this list updated…
More on ..
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python-networkdays-1.1.tar.gz
.
File metadata
- Download URL: python-networkdays-1.1.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f0d67ab46aeff00a8da43e7161b17769788e16ca2f783eb9fb0f2d6d8eea12d |
|
MD5 | 3a196de3916661c0cdda69b3f33e305f |
|
BLAKE2b-256 | d99aefd5a8d1f3927c5bd13f5edd8ad046749898e4302441680bb7bd5dc6b5d1 |
File details
Details for the file python_networkdays-1.1-py3-none-any.whl
.
File metadata
- Download URL: python_networkdays-1.1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ac15f44c81038ff5c0d2a14eb3b653aa44fc79158a3b31a956a2f471b9713fd |
|
MD5 | 90576f9b8d9aa783ccb1b71c7f30cf72 |
|
BLAKE2b-256 | c542cee400c2e90d2993b5855fbeeda31ccf08e084ec277a5db29036154546d9 |