[英]Python - Pandas: Construct date with year, week of year and day of week
Is there a way, using pandas, to construct a Timestamp
based on 3 input: 有没有一种方法,可以使用熊猫根据3种输入构造
Timestamp
:
In that particular example, the result would be Timestamp('2010-01-18')
在该特定示例中,结果将为
Timestamp('2010-01-18')
Anyone have a hint of a clever way to achieve this? 任何人都有实现这一目标的聪明方法的暗示吗?
You can generate a date using the logic you've provided like this: 您可以使用提供的逻辑生成日期,如下所示:
>>> datetime.datetime.strptime("2010-3-Monday", "%Y-%W-%A")
datetime.datetime(2010, 1, 18, 0, 0)
You may need to adjust your format, depending on what, exactly, you are passing to strptime
, but you can find the appropriate formatting options here 您可能需要调整格式,具体取决于传递给
strptime
,但是您可以在此处找到适当的格式设置选项
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.