简体   繁体   English

如何指定在大熊猫(小时,分钟,秒,日,月,年)中读取时间值时首先出现的内容?

[英]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.

相关问题 Python:如何以年月日时分秒格式转换谷歌位置时间戳? - Python: How to convert google location timestaMps in a year-month-day-hour-minute-seconds format? 这个时间格式是什么:XX:XX.X,以及如何在 Python 中将其转换为通常的年月日时分秒 - what is this time format: XX:XX.X, and how to transfer it to usual year-month-day-hour-minute-second in Python 如何为年/月/日/小时/分钟/秒创建日期时间的Pandas列? - How to create a Pandas column for datetime from year / month/ day / hour / minute / second? 如何在python中获取当前时间并分解为年、月、日、小时、分钟? - How to get current time in python and break up into year, month, day, hour, minute? python中的时间戳(年、月、日、小时、分钟) - Timestamp in python (year,month,day,hour,minute) 按分钟,小时,天,月和年分组? - groupby minute, hour, day, month, and year? 如何找到最接近以月/日/年小时/分钟/秒 AM 格式给出的另一个日期和时间的日期和时间 - How to find a date and time nearest another date and time given in month/day/year hour/minute/second AM format Pandas:绘图时忽略索引中的年份,但保留小时/天/月 - Pandas: ignore year in index when plotting but keep hour/day/month 用Python解析年,月,日,时,分,秒 - Parsing year, month, day, hour, minute, second in Python 从当前日期时间中提取年、月、日、小时和分钟 - Extracting year, month, day, hour and minute from the current datetime
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM