In [1]:
import random
import datetime
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
dates = [datetime.datetime(2015,1,1,0, 30) + datetime.timedelta(hours = n) for n in range(365*24*3 + 366*24)]
In [3]:
random.choice(dates)
Out[3]:
datetime.datetime(2017, 3, 16, 20, 30)
In [4]:
random.choice(dates)
Out[4]:
datetime.datetime(2016, 4, 9, 4, 30)
In [5]:
random_dates = np.array([])
for n in range(10000):
    random_dates = np.append(random_dates, random.choice(dates))
In [6]:
fig, ax = plt.subplots(figsize = (15, 5))
ax.hist(random_dates)
Out[6]:
(array([1048., 1000.,  993.,  989., 1019., 1020., 1002.,  981.,  981.,
         967.]),
 array([735599.3125, 735745.3625, 735891.4125, 736037.4625, 736183.5125,
        736329.5625, 736475.6125, 736621.6625, 736767.7125, 736913.7625,
        737059.8125]),
 <a list of 10 Patch objects>)
In [ ]: