簡體   English   中英

如何指定在大熊貓(小時,分鍾,秒,日,月,年)中讀取時間值時首先出現的內容?

[英]How to specify what comes first when reading time values in pandas (hour, minute, seconds, day, month, year)?

我有以下時間數據:

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

該數據采用歐洲時間格式。 (日月年)。 我想告訴大熊貓按順序閱讀日期,問題是當我嘗試pd.to_datetime(format = "%d/%m/%Y")它不起作用,它說我的數據不是在那種格式中,我想這是因為我還有小時分鍾和秒鍾,我不會告訴大熊貓如何閱讀它。 但我無法弄明白。

我的問題很簡單,我怎樣才能以這種格式讀取我的數據?

我想要的時間格式是天,月,年,小時,分鍾,秒。

非常感謝你提前

to_datetime使用參數format ,參數可以在http://strftime.org/找到:

df['date'] = pd.to_datetime(df['date'], format='%d/%m/%y %H:%M:%S,%f')

說明:

%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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM