我是新的python,並有一個基本的問題,我無法在網上找到解決方案。在Numpy中導出ISO日期
我有一個名爲IBTsample.txt表,包含:
- 季節,ISO_time,經緯度,枚舉
- 2009,2009-12-24 12:00:00,6.50,85.00, 2
- 2009,2009-12-25 06:00:00,8.00,84.50,6
- 2009,2009-12-25 00:00:00,7.00,84.50,4
- 2009,2009- 12-24 18:00:00,6.50,85.00,3
- 2009,2009-12-24 09:00:00,6.50,8 5.00,1
- 2009,2009-12-25 03:00:00,7.00,84.50,5
我想要做的就是導入它作爲numpy的陣列,做一些處理(用於時間只是簡單地對記錄日期進行排序)並將處理後的表格導出爲新的.txt文件。
from numpy import *
import pylab
rawtable = loadtxt('IBTsample.txt', delimiter=',', skiprows=1, converters= {1:pylab.datestr2num},\
dtype={'names':('Season','ISO_time','Latitude','Longitude','Enum'),\
'formats':('uint16','float','float16','float16','uint8')})
sortable = (sort(rawtable, order=('ISO_time'))).copy()
savetxt('IBTsorted.txt', sortable, fmt='%d,%.3f,%.1f,%.1f,%d')
我有TI使用pylab.datestr2num功能輸入過程中卻找不到一個反函數導出的日期和時間的ISO格式。
任何幫助或想法都會很有幫助。