Open SamanthaChen opened 5 years ago
check sqlite3 documentation, as pandasql wrapps your dfs, "sends" them to sqlite3, executes your sql query in sqlite3, and returns results as pandas_dataframe
as for https://github.com/yhat/pandasql/issues/78
EXP is not in standard SQLite.
It's available in a C extension of SQLite "extension-functions.c" described here https://www.sqlite.org/contrib?orderby=date
The possible workaround is you to inject the needed function in Python in SQLite database.
It would do something like that, in a nasty proof of concept.
as for #78
EXP is not in standard SQLite.
It's available in a C extension of SQLite "extension-functions.c" described here https://www.sqlite.org/contrib?orderby=date
The possible workaround is you to inject the needed function in Python in SQLite database.
It would do something like that, in a nasty proof of concept.
I have tried your solution, but I get:
DatabaseError: Execution failed on sql 'pydef py_sqrt(s):
"sqrt function from Python Math standard library"
import math as py_math
return ("%s" % py_math.sqrt(float(s)));': near "pydef": syntax error
for the statement:
st = """
pydef py_sqrt(s):
"sqrt function from Python Math standard library"
import math as py_math
return ("%s" % py_math.sqrt(float(s)));
select r.* [...]
Am I missing something? Also included the baresql bits from your snippet.
On all latest python releases of early may, math functions are native in SQLite-0.35.5 embedded in Python. So you won't need my trick, and worst case you can copy the sqlite3.dll from a new python into your more full size existing environement
@stonebig I'm running pandasql==0.7.3
in python 3.11.3 with sqlite3.version==2.6.0
and sqlite3.sqlite_version==3.37.0
but math functions still are not working.
I've been able to compile sqlite with the -DSQLITE_ENABLE_MATH_FUNCTIONS flag, but am unsure how to make the python libraries use my version. Has anyone had success here?
I am trying to use function 'exp' in pandassql, but the error throwed:
PandaSQLException: (sqlite3.OperationalError) no such function: exp [SQL: 'select *, 1/(1+exp(-(tree0+tree1+tree2+tree3+tree4+tree5+tree6+tree7+tree8+tree9))) as score from res_df;']