Python Forum
Appropriate data-structure / design for business-day relations (week/month-wise)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Appropriate data-structure / design for business-day relations (week/month-wise)
#1
Hi guys,

I'm just trying to figure out "the best", i.e. cleanest and most appropriate way to do the following:

For a specified day, e.g. thursday, 22th of April 2021, I want to know / calculate: Is it the last working day of the current week, if not, what is the last working day of the current week? The same for whole month. And what's more: I want to know what was the last working day of the previous week (e.g. Friday, 16th of April) and the previous month (e.g. wednesday 31th of March).

As a basic condition, only Monday - Friday are working days, and on top of that, I have a list of days which I define as non-working days, which could be days during the week, or also at the end.

E.g. in case I define Friday [30th of April] and [Wednesday and Thursday 5th/6th of May] as non-working days, when I input [Tuesday 4th of May] into my algorithmn, it would say: [7th of May] is the last working day of the week and Thursday 29th of April was the last working day of the previous week.

What would be the "best" data-structure to handle this?
Is there a known algorithmn or even a suitable package which could be used?
In case no, I was wondering whether it makes sense to have some sort of pre-calculated list which are somehow interconnected, e.g. like a graph.

E.g. in a graph: Every day would be a node and be connected to the previous and the next working day nodes, it is connected to its working week (e.g. CW22), which, again is connected to its month. Every week and every month has a previous and a next week/month node.

By doing so, I would only have to search the node for a specific day, e.g. 22th of April, and from there, I could go to the week-Node the day belongs to, from there to the previous week-Node and from there to the last working day Node of that week-Node.

I'm just not clear whether I'm thinking way to overhead here!?

Thanks so much
Reply


Messages In This Thread
Appropriate data-structure / design for business-day relations (week/month-wise) - by sx999 - Apr-22-2021, 06:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  get list of dates in past month, current and upcoming month jacksfrustration 4 620 Feb-03-2024, 06:37 PM
Last Post: deanhystad
  Python Resampling: How do I obtain the value of the last week of the month? JaneTan 2 1,063 Dec-12-2022, 12:49 AM
Last Post: JaneTan
  Element wise computation divon 2 1,621 Jun-01-2022, 02:36 AM
Last Post: divon
  How can I add certain elements in this 2d data structure and calculate a mean TheOddCircle 3 1,601 May-27-2022, 09:09 AM
Last Post: paul18fr
  Print first day of the week as string in date format MyerzzD 2 2,064 Sep-29-2021, 06:43 AM
Last Post: MyerzzD
  what data structure to use? Winfried 4 2,872 Mar-16-2021, 12:11 PM
Last Post: buran
  Yahoo_fin, Pandas: how to convert data table structure in csv file detlefschmitt 14 7,914 Feb-15-2021, 12:58 PM
Last Post: detlefschmitt
  How to use Bunch data structure moish 2 2,962 Dec-24-2020, 06:25 PM
Last Post: deanhystad
  Generating random business cards Inkanus 2 2,241 Dec-08-2020, 09:41 PM
Last Post: buran
  Correct data structure for this problem Wigi 13 4,729 Oct-09-2020, 11:09 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020