[英]numpy date issue - convert floating point year-week format to numpy's date format
I have a floating point value representing the date with year-week format as follows:我有一个浮点值,表示年-周格式的日期,如下所示:
201423.0000
where the 2014 is the year and 23 is the week number.其中 2014 是年份,23 是周数。 How can I convert this floating point value to numpy's datetime format ?如何将此浮点值转换为 numpy 的日期时间格式?
Here is one way:这是一种方法:
In [43]: a = 201423.0000
In [48]: date = np.datetime64(str(int(a // 100)), 'Y') + np.timedelta64(int(a%100), 'W')
In [49]: date
Out[49]: numpy.datetime64('2014-06-05')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.