[英]How to specify what comes first when reading time values in pandas (hour, minute, seconds, day, month, year)?
I have the following time data: 我有以下时间数据:
0 08/01/16 13:07:46,335437
1 18/02/16 08:40:40,565575
2 14/01/16 22:23:23,606399
3 18/01/16 12:12:46,114231
4 18/01/16 17:09:11,477728
5 20/01/16 12:56:20,432586
6 18/01/16 21:12:53,645333
7 25/01/16 17:29:34,540325
8 16/02/16 10:03:08,698522
9 16/02/16 13:49:54,977352
10 25/02/16 12:17:01,271601
This data is in european time format. 该数据采用欧洲时间格式。 (day, month, year).
(日月年)。 I want to tell pandas to read the dates in that order, the problem is that when i try
pd.to_datetime(format = "%d/%m/%Y")
it won't work, it says that my data is not in that format, i suppose that this is because i have also the hours minutes and seconds and i'm not telling pandas anything about how to read it. 我想告诉大熊猫按顺序阅读日期,问题是当我尝试
pd.to_datetime(format = "%d/%m/%Y")
它不起作用,它说我的数据不是在那种格式中,我想这是因为我还有小时分钟和秒钟,我不会告诉大熊猫如何阅读它。 But i can't figure it out. 但我无法弄明白。
My question is simple, how can i read my data in this format?? 我的问题很简单,我怎样才能以这种格式读取我的数据?
My desired time format is days, month, year, hours, minutes, seconds. 我想要的时间格式是天,月,年,小时,分钟,秒。
Thank you very much in advance 非常感谢你提前
Use parameter format
in to_datetime
, parameters is possible find in http://strftime.org/
: 在
to_datetime
使用参数format
,参数可以在http://strftime.org/
找到:
df['date'] = pd.to_datetime(df['date'], format='%d/%m/%y %H:%M:%S,%f')
Explanation: 说明:
%d - match day
%m - match month
%y - match year in format YY
%H - match hour in 24h format
%M - match minute
%S - match second
%F - match microsecond
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.