0

I am able to create date randomly but I want to create date by giving the time range as well.

Here is the code for creating date randomly,

import pandas as pd 
import numpy as mp
def random_dates(start, end, n=10000):

    start_u = start.value//10**9
    end_u = end.value//10**9

    return pd.to_datetime(np.random.randint(start_u, end_u, n), unit='s')

start = pd.to_datetime('2019-01-01 07:00:00')
end = pd.to_datetime('2019-09-30 23:59:00')
X = random_dates(start, end)
df = pd.DataFrame(X, columns=['date'])

But Timerange is not working.

halfer
  • 19,824
  • 17
  • 99
  • 186
venkat
  • 1,203
  • 3
  • 16
  • 37
  • What is your problem, is not clear from your question. Add expected output. – Dani Mesejo Nov 13 '19 at 19:31
  • @DanielMesejo, I want a date time within the specific time range – venkat Nov 13 '19 at 19:32
  • Note that we prefer a technical style of writing here. We gently discourage greetings, hope-you-can-helps, thanks, advance thanks, notes of appreciation, regards, kind regards, signatures, please-can-you-helps, chatty material and abbreviated txtspk, pleading, how long you've been stuck, voting advice, meta commentary, etc. Just explain your problem, and show what you've tried, what you expected, and what actually happened. – halfer Dec 10 '19 at 09:35

0 Answers0