AbdullahO / tspdb

tspdb: Time Series Predict DB
Apache License 2.0
184 stars 58 forks source link

python script select create_pindex call error #21

Open wilbertmatthew opened 2 years ago

wilbertmatthew commented 2 years ago

I wrote a simple python3.5 script to test the create_pindex call taken from the 2020 NeurLPS tspDB Demo.ipynb example. I run the example first in colab then converted into a .py file. Used the cursor.execute call in a simpler test file a shown below.

import psycopg2 import tspdb

conn = psycopg2.connect(dbname="postgres", user="demo", host="127.0.0.1", password="00", port="5432") cursor = conn.cursor()

cursor.execute('SELECT * FROM electricity')

cursor.execute("""select create_pindex('electricity', 'time','{"h1","h2","h3","h4","h5","h6","h7","h8","h9","h10"}','pindex1');""")

rows = cursor.fetchall()

for table in rows:

#print(table)

conn.close()

When run I get the following error:

Traceback (most recent call last): File "testconnection.py", line 13, in cursor.execute("""select create_pindex('electricity', 'time','{"h1","h2","h3","h4","h5","h6","h7","h8","h9","h10"}','pindex1');""") psycopg2.errors.ExternalRoutineException: TypeError: unsupported operand type(s) for %: 'Int64Index' and 'int' CONTEXT: Traceback (most recent call last): PL/Python function "create_pindex", line 18, in TSPD.create_index() PL/Python function "create_pindex", line 269, in create_index PL/Python function "create_pindex", line 354, in write_model PL/Python function "create_pindex", line 488, in write_tsmm_model PL/Python function "create_pindex"

Tried python2.7, python3.5 postgresql version - PostgreSQL 12.7 (Ubuntu 12.7-1.pgdg16.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609, 64-bit

Ubuntu 16.04

Thanks

Wilbert Jackson

AbdullahO commented 2 years ago

This seems like an error from pandas. What version of Pandas do you have installed? can you make sure you have the latest version?

wilbertmatthew commented 2 years ago

Thanks for your response. I have different tested different versions of Pandas. I am currently using 0.24.2 and getting the same error. If I run some of the Pandas test programs that use Int64Index I do not get the error. Also if I place pd.Int64Index(np.arange(10, 30), name="t") from one of the test programs in my test tspdb program I do not get an error. How can I step through create_pindex function?

AbdullahO commented 2 years ago

Can you recreate the error in google colab? It's hard for me to pinpoint the problem. Are you using your own data? or is it the same data in 2020 NeurLPS tspDB Demo.ipynb?