import numpy as np data=np.arange(100000000000001,100000000100001) data.shape #(100000,)
效果:随机生成一个字符串日期列表 ['2023-05-25 11:09:00', '2023-05-25 09:30:59', '2023-05-24 18:34:03', '2023-05-24 15:50:42', '2023-05-23 21:12:59', '2023-05-23 17:52:01', '2023-05-23 09:46:55'] 代码 import datetime import numpy as np def minute_one_year(minute_min=10): """年交易时间数据:分钟列表 - 依据该分钟列表,按时间相减,可得出一系列日期 - minute_month:最小单位为分钟,minute_bymonth为一个月的分钟数 - count_month:一个月的交易笔数 - 伪算法 - 以1年的总分钟数为最大尺度,10分钟为最小尺度,取一定数量的随机数 - 每月随机发生count_month笔交易 """ minute_month = 24*60*30 minute_year = minute_month*12 count_month = np.random.randint(low=0,high=100) count_year = count_month*12 a=np.random.randint(low=minute_min, high=minute_year, size=count_year) a.sort() return a.tolist() m_time = minute_one_year() def ymdhms_time(minute_list, max_count=1000): """根据分钟列表,从当前日期开始生成一系列日期 - 返回 - %Y-%m-%d %H:%M:%S格式 日期字符串 列表 """ t1 = [] count = 0 for m in minute_list: if count >= max_count: break day1 = datetime.datetime.now() - datetime.timedelta(minutes=m*0.99) ss = day1.strftime('%Y-%m-%d %H:%M:%S') t1.append(ss) count = count+1 return t1 res = ymdhms_time(minute_list=m_time, max_count=7) res ['2023-05-25 11:09:00', '2023-05-25 09:30:59', '2023-05-24 18:34:03', '2023-05-24 15:50:42', '2023-05-23 21:12:59', '2023-05-23 17:52:01', '2023-05-23 09:46:55'] from tpf import year1_ymh year1_ymh(count=3, dt_format='%Y-%m-%d') |
from tpf import random_yyyymmdd df["dtt"] = random_yyyymmdd(dt_format="%Y-%m-%d") df["dtt"] 0 2016-11-24 1 2016-11-24 2 2016-11-24 3 2016-11-24 4 2016-11-24 ... 564 2016-11-24 565 2016-11-24 566 2016-11-24 567 2016-11-24 568 2016-11-24 Name: dtt, Length: 569, dtype: object |
|
|
|