yhat / pandasql

sqldf for pandas
MIT License
1.34k stars 185 forks source link

Standard Deviation function is not working #78

Open SivaramKanagaraj opened 5 years ago

SivaramKanagaraj commented 5 years ago

I trying to get standard deviation of a variable, but i getting below error.

PandaSQLException: (sqlite3.OperationalError) no such function: STDEV

stonebig commented 5 years ago

STDEV 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.

image

raprice3 commented 3 years ago

I have used the extension-functions.c SQLite extension (https://www.sqlite.org/contrib/download/extension-functions.c) mentioned above in the SQLite command line and in SQLite studio, it isn't very hard to do. The R package RSQLite includes these extension functions already (see https://cran.r-project.org/web/packages/sqldf/README.html), which makes using SQLite in R very useful.

This is a feature request -- is it possible to get those extension functions loaded automatically? It would be tremendously helpful.

Thanks,

Richard