I need to work with large dimension data frame with multi index, so i tried to create a data frame to learn how to store it in an hdf5 file. The data frame is like this: (with the multi index in the first 2 columns)
Symbol Date 0
C 2014-07-21 4792
B 2014-07-21 4492
A 2014-07-21 5681
B 2014-07-21 8310
A 2014-07-21 1197
C 2014-07-21 4722
2014-07-21 7695
2014-07-21 1774
I'm using the pandas.to_hdf but it creates a "Fixed format store", when I try to select the datas in a group:
store.select('table','Symbol == "A"')
it returns some errors and the main problem is this
TypeError: cannot pass a where specification when reading from a Fixed format store. this store must be selected in its entirety
Then i tried to append the DataFrame like this:
store.append('ts1',timedata)
and that should create a table, but that gives me another error:
TypeError: [unicode] is not implemented as a table column
So i need the code to store the data frame in a table in hdf5 format and to select the datas from a single index (for that purpose i found this code: store.select('timedata','Symbol == "A"') )
doubleIndex = c.execute("SELECT date, symbol, qty FROM stocks") double = c.fetchall() serie = pandas.DataFrame(double,columns=['Date','Symbol', 'DateValue']) serie['Date'] = pandas.to_datetime(serie['Date']) serie = serie.sort('Date',ascending=True)index = pandas.MultiIndex.from_arrays([serie['Symbol'],serie['Date']], names=['Symbol','Date'])df[column] = df[column].astype(str)to change the unicode to string. cannot store unicode in py2.7. you should useread_sqlas well (and possibly turn off the unicode options in sqlite3)