您好,登錄后才能下訂單哦!
這篇文章主要介紹Pandas中Cookbook時間戳處理的示例分析,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
上代碼
# -*-coding:utf-8-*- # by kevinelstri # 2017.2.17 # --------------------- # Chapter 8 - How to deal with timestamps.ipynb # --------------------- import pandas as pd ''' 8.1 Parsing Unix timestamps ''' popcon = pd.read_csv('../data/popularity-contest', sep=' ') # print popcon.head() popcon.columns = ['atime', 'ctime', 'package-name', 'mru-program', 'tag'] # print popcon[:5] print popcon['atime'].dtype popcon['atime'] = popcon['atime'].astype(int) # print popcon['atime'][:5] # popcon['ctime'] = popcon['ctime'].astype(int) popcon['atime'] = pd.to_datetime(popcon['atime']) # popcon['ctime'] = pd.to_datetime(popcon['ctime'], unit='s') # print popcon['atime'][:5] popcon = popcon[popcon['atime'] > '1970-01-01'] nonlibraries = popcon[~popcon['package-name'].str.contains('lib')] nonlibraries.sort('ctime', ascending=False)[:10]
以上是“Pandas中Cookbook時間戳處理的示例分析”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。