更改日期订单
我有包含一组日期的CSV文件。
格式就像:
14/06/2000
15/08/2002
10/10/2009
09/09/2001
01/03/2003
11/12/2000
25/11/2002
23/09/2001
出于某种原因pandas.to_datementement()
不起作用。 因此,我已经将列分成3列,即日,月和年。 现在,我试图将无“/”的列组合在一起:
df["period"] = df["y"].astype(str) + df["m"].astype(str)
但是问题不是得到:
200006
我得到:
20006
丢失了一个零。 你能帮我吗?
I have csv file containing a set of dates.
The format is like:
14/06/2000
15/08/2002
10/10/2009
09/09/2001
01/03/2003
11/12/2000
25/11/2002
23/09/2001
For some reason pandas.to_datetime()
does not work on my data.
So, I have split the column into 3 columns, as day, month and year.
And now I am trying to combine the columns without "/" with:
df["period"] = df["y"].astype(str) + df["m"].astype(str)
But the problem is instead of getting:
200006
I get:
20006
One zero is missing.
Could you please help me with that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将使您可以使用日期列,然后将其变成pd.to_datetime()
This will allow you to take the column of dates and turn it into pd.to_datetime()
dayfirst =
参数可能会帮助您:The
dayfirst=
parameter might help you: