HDF store request

I created hd5 file

hdf=pandas.HDFStore(pfad)
hdf.append('df', df, data_columns=True)

I have a list containing numpy.datetime64 values โ€‹โ€‹called expirations, and try reading part of the hd5 table as a data frame that has values โ€‹โ€‹between the expiration [1] and expirations [0] in the "expiration" column. Column expiration entries are in Timestamp format ('2002-05-18 00:00:00').

I use the following command:

df=hdf.select('df', where=('expiration<expiration[1] & expiration>=expirations[0]'))

However, I get a ValueError: Impossible to parse x How should this be done correctly?

df.dtypes
Out[37]: 
adjusted stock close price           float64
expiration                    datetime64[ns]
strike                                 int64
call put                              object
ask                                  float64
bid                                  float64
volume                                 int64
open interest                          int64
unadjusted stock price               float64

df.info
Out[36]: 
<bound method DataFrame.info of             adjusted stock close price expiration  strike call put      ask  date                                                                          
2002-05-16                     5047.00 2002-05-18    4300        C  802.000   

There are more columns, but they are not of interest to the query.

0
source share
1 answer

The problem is solved!

I got expiration through

 df_expirations=df.drop_duplicates(subset='expiration')
 expirations=df['expiration'].values

, , tz datetime. ,

 expirations=df['expirations']

:   del df   df = hdf.select('df', = ('expiration = expirations [1]'))

, datetime.

0

All Articles