2016-03-22 63 views
0

我將數據存儲在hdf5文件中。奇怪的是我選擇了一個具有相同條件的表,但HDFStore給出了不同的答案。選擇條件相同,但HDFStore給出不同的答案

誰能告訴我爲什麼?

In [2]: import pandas as pd 
In [3]: store=pd.HDFStore("./data/m2016.h5","r") 
In [4]: store 
Out[4]: 
<class 'pandas.io.pytables.HDFStore'> 
File path: ./data/m2016.h5 
/m2016   frame_table (typ->appendable,nrows->37202055,ncols->6,indexers->[index],dc->[dt,code]) 
In [5]: a=store.select('m2016',where="code='000001'") 
In [6]: b=store.select('m2016',where="code='000001'") 
In [7]: a.shape 
Out[7]: (2388318, 6) 
In [8]: b.shape 
Out[8]: (2374525, 6) 
In [9]: a.head() 
Out[9]: 
        dt market code price volume preclose 
85920 2016-01-04 09:30:00  0 000001 11.98 1102900  11.99 
85921 2016-01-04 09:31:00  0 000001 11.96 289100  11.99 
85922 2016-01-04 09:32:00  0 000001 11.97 361800  11.99 
85923 2016-01-04 09:33:00  0 000001 12.00 279200  11.99 
85924 2016-01-04 09:34:00  0 000001 12.00 405600  11.99 

我測試了它在我所有的三臺電腦,結果爲:

PC1,操作系統:Win2012server,蟒蛇:winpython 2.7.10.3(64位),選擇結果是錯誤的。

PC2,os:Win10,python winpython 2.7.10.3(64bits),select result is wrong。

PC3,os:Win7,python:Winpython 2.7.10.3(64bits),select result is ok!

也許HDFStore.select只能運行在Win7上?

+0

我測試了它在我的三臺電腦,結果爲: – hoot

+0

你檢查你的熊貓的版本不同的電腦上? – jrjc

回答

0

也許操作系統的默認編碼有所不同?

將這項工作B = store.select( 'm2016',其中= 「代碼= u'000001' 」)

+0

我測試了b = store.select('m2016',where =「code = u'000001'」),但沒有任何變化。 – hoot

0

我已經在我在Win7 PC測試了它,它仍然有隨機錯誤的結果。

In [1]: import pandas as pd 
In [2]: cd /projects 
C:\projects 
In [3]: store=pd.HDFStore("./data/m2016.h5","r") 
In [4]: d0=store.select("m2016",where='dt<Timestamp("2016-01-10")') 
In [5]: d1=store.select("m2016",where='dt<Timestamp("2016-01-10")') 
In [6]: d0.shape 
Out[6]: (6917149, 6) 
In [7]: d1.shape 
Out[7]: (4199769, 6) 
In [8]: d0.tail() 
Out[8]: 
         dt market code price volume preclose 
455381 2016-04-21 11:11:00  1 600461 13.33 16400  13.2 
455386 2016-04-21 11:16:00  1 600461 13.36 13800  13.2 
455387 2016-04-21 11:17:00  1 600461 13.37 8300  13.2 
455388 2016-04-21 11:18:00  1 600461 13.36 9800  13.2 
455389 2016-04-21 11:19:00  1 600461 13.34 15300  13.2 
In [9]: d1.tail() 
Out[9]: 
         dt market code price volume preclose 
573543 2016-04-22 14:03:00  1 601333 3.94 8200  3.97 
573548 2016-04-22 14:08:00  1 601333 3.96 45000  3.97 
573549 2016-04-22 14:09:00  1 601333 3.96 8800  3.97 
573550 2016-04-22 14:10:00  1 601333 3.97 10700  3.97 
573551 2016-04-22 14:11:00  1 601333 3.96 6800  3.97 
In [10]: !ptdump m2016.h5 
/(RootGroup) '' 
/m2016 (Group) '' 
/m2016/table (Table(50957318,), shuffle, zlib(9)) '' 

我上傳我的HDF5文件here

+0

你的文件太大了 –

相關問題