熊猫的日期时间转换

问题描述 投票:0回答:3

我正在从其中一个日期存储为的文件之一中获取数据20 March我想使用大熊猫转换为20/03/2020

我尝试使用strftimeto_datetime使用错误,但仍然无法转换。

此外,当我按日期分组时,它以数字形式存储date列:1 January,1 February,1 March then 2 January,2 February, 2 March

我该如何解决?

python pandas pandas-groupby
3个回答
0
投票
import pandas as pd

def to_datetime_(dt):
    return pd.to_datetime(dt + " 2020")

0
投票

如果year始终为2020,则使用以下代码:


0
投票

做,

© www.soinside.com 2019 - 2024. All rights reserved.