startdate = np.datetime64('2022-01-01T00:00:00.000000') # 10000 days. This array contains 0 (Day 0), 1 (Day 1), etc day_offsets = np.arange(10000, dtype=np.int64) usec_per_day = int(1e6) * 86400 # 86.4k sec per day, 1e6 microseconds per second # Compute microseconds offset from first day usec_offsets = day_offsets * usec_per_day # Compute timestamps timestamps = startdate + usec_offsets # Mark start of month in boolean array is_start_of_month = np.zeros_like(timestamps, dtype=bool) for index, timestamp in np.ndenumerate(timestamps): is_start_of_month[index[0]] = timestamp.astype(datetime).day == 1
Using this method, timestamps
will be the start of each day
array(['2022-01-01T00:00:00.000000', '2022-01-02T00:00:00.000000', '2022-01-03T00:00:00.000000', ..., '2101-12-30T00:00:00.000000', '2101-12-31T00:00:00.000000', '2102-01-01T00:00:00.000000'], dtype='datetime64[us]')