博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python format 时间格式
阅读量:4676 次
发布时间:2019-06-09

本文共 375 字,大约阅读时间需要 1 分钟。

trainData['survey_time'] = pd.to_datetime(trainData['survey_time'],format = '%Y/%m/%d %H:%M')

trainData['survey_time'] = trainData['survey_time'].dt.year

格式化日期转换为dt 然后直接取年

python中时间日期格式化符号:

%y 两位数的年份表示(00-99)

%Y 四位数的年份表示(000-9999)

%m 月份(01-12)

%d 月内中的一天(0-31)

%H 24小时制小时数(0-23)

%I 12小时制小时数(01-12) 

%M 分钟数(00=59)

%S 秒(00-59)

转载于:https://www.cnblogs.com/NWNU-LHY/p/11165040.html

你可能感兴趣的文章
java中== 和 .equals()的区别
查看>>
网络流学习笔记
查看>>
jquery validate
查看>>
模板函数与模板类
查看>>
WPF月视图控件
查看>>
Android指纹识别
查看>>
C#设计模式之十六观察者模式(Observer Pattern)【行为型】
查看>>
VS中的预先生成事件和后期生成事件
查看>>
JavaScript知识(二)
查看>>
Windows phone 8 学习笔记(7) 设备
查看>>
SQL Server的备份
查看>>
SQL Server 重置Identity标识列的值(INT爆了)
查看>>
DB2 Error
查看>>
辗转相除法的原理
查看>>
C Primer Plus note7
查看>>
shell 常用命令
查看>>
How to show only next line after the matched one?
查看>>
手续费
查看>>
yii2框架随笔19
查看>>
为什么要使用getter/setter
查看>>