您好,登錄后才能下訂單哦!
這篇文章主要介紹Pandas中Cookbook時(shí)間戳處理的示例分析,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
上代碼
# -*-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時(shí)間戳處理的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。