Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9154561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:26:50+00:00 2026-06-17T12:26:50+00:00

I am trying to generate some test data through python. (my app is not

  • 0

I am trying to generate some test data through python. (my app is not in python but python seems easy and succinct for data generation). I want to simulate a typical work day of an employee, by generating ‘time slots’ of activities. Below function needs to generate ‘n‘ number of time slot between start and end(with some random gap between to seem natural) with a total(total_hrs).

slots = [] #list of slot == {start:<>, end:<>}
def time_slot(start, end, n, total_hrs):
  # generate n non-overlapping time slot between start and end (with some random gap between to seem natural)

print (slots)

Eg:

time_slot( "1/1/2013 9:00", "1/1/2013 17:00", 3, 8)

[ {start: "1/1/2013 9:00", end: "1/1/2013 10:30"}, ...., {start: "1/1/2013 14:00", end: "1/1/2013 16:44"}]

#total time == 8
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:26:50+00:00Added an answer on June 17, 2026 at 12:26 pm

    I can give an outline of what I would do:

    1. draw n random numbers
    2. s = sum all numbers
    3. convert total_hrs to total_min
    4. make the work-chunks: chunks = [c/s * total_min for c in numbers]
    5. calc the difference between end - start and total_hrs
    6. do the same steps 1 – 4 again for this difference to get the gaps (use n+1 to allow for a gap at the beginning
    7. Finally convert all the chunks to datetime.timedelta and add the timedelta consecutively to start (already at the beginning you should have converted start and end to datetime.date)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to generate some test data. Say I have 1000 appointments that
I have been trying to generate a heatmap in R for some microarray data
I was trying to generate some plots for t, z and chi-square test. I
I'm trying to test some streaming file upload/download code that I've just written, but
I am trying to generate some code using Acceleo. I am constructing my model
I'm trying to generate some html programmatically in my code behind for a user
I am trying to generate some code using CodeDom. I wanted to know if
I'm trying to generate some stubs for a WSDL (using xmlbeans) and keep running
currently i'm trying to use imagick to generate some images without saving them on
I'm having some problems trying to figure out how to generate a Google Map

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.