基于PyTables將(高頻)時序數據保存為HDF5文件高效訪問的庫:TsTables

jopen 9年前發布 | 58K 次閱讀 TsTables Python開發

TsTables —— Python下基于PyTables將(高頻)時序數據保存為HDF5文件高效訪問的庫。

# Class to use as the table description
class BpiValues(tables.IsDescription):
    timestamp = tables.Int64Col(pos=0)
    bpi = tables.Float64Col(pos=1)

Use pandas to read in the CSV data

bpi = pandas.read_csv('bpi_2014_01.csv',index_col=0,names=['date','bpi'],parse_dates=True)

f = tables.open_file('bpi.h5','a')

Create a new time series

ts = f.create_ts('/','BPI',BpiValues)

Append the BPI data

ts.append(bpi)

Read in some data

read_start_dt = datetime(2014,1,4,12,00) read_end_dt = datetime(2014,1,4,14,30)

rows = ts.read_range(read_start_dt,read_end_dt)

rows will be a pandas DataFrame with a DatetimeIndex.</pre>

項目主頁:http://www.baiduhome.net/lib/view/home/1424832458343

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!