I am trying to create a table structure through tb.IsDescription class, then create a .h5 file and populate it with a Pandas Dataframe with Datetime index, using TsTables package. I have already tested the Dataframe and the date time Indexing and both seem to be fine. I believe the issue is with the TsTable package, as it remains 'Unused import statement'. The error I get is: " AttributeError: module 'pandas.tseries' has no attribute 'index' ". The reason I am using the TsTAble is that I have heard it is faster than other modules. Any suggestions how to resolve this issue, or any substitute method?
import numpy as np
import pandas as pd
import tables as tb
import datetime as dt
path = r'C:\Users\--------\PycharmProjects\pythonProject2'
no = 5000000 # number of time steps
co = 3 # number of time series
interval = 1. / (12 * 30 * 24 * 60) # the time interval as a year fraction
vol = 0.2 # volatility
rn = np.random.standard_normal((no, co))
rn[0] = 0.0 # sets the initial random numbers to zero
paths = 100 * np.exp(np.cumsum(-0.5 * vol ** 2 * interval + vol * np.sqrt(interval) * rn, axis=0))
# simulation based on an Euler discretization
paths[0] = 100 # Sets the initial values of the paths to 100
dr = pd.date_range('2019-1-1', periods=no, freq='1s')
print(dr[-6:]) # the date range appears fine
df = pd.DataFrame(paths, index=dr, columns=['ts1', 'ts2', 'ts3'])
print(df.info(verbose=True)) # df is pandas Dataframe and appears fine
print(df.head()) # tested a fraction of the data, it is fine
import tstables as tstab # I get Unused import statement
class ts_desc(tb.IsDescription):
timestamp = tb.Int64Col(pos=0) # The column for the timestamps
ts1 = tb.Float64Col(pos=1) # The column to store numerical data
ts2 = tb.Float64Col(pos=2)
ts3 = tb.Float64Col(pos=3)
h5 = tb.open_file(path + 'tstab.h5', 'w')
ts = h5.create_ts('/', 'ts', ts_desc)
ts.append(df) # !!!!! the error I get is from this code line !!!!
# value error raised is: if rows.index.__class__ != pandas.tseries.index.DatetimeIndex:
AttributeError: module 'pandas.tseries' has no attribute 'index' `