Search code examples
pythonpandassqliteerror-handlingpandasql

Why am I getting ObjectNotExecutableError from pandasql?


This started after I updated my data science libraries to the latest version. Now I get his error after running any of the queries I was running before, but I'm not completly certain from which library or function this is coming from? How can I know which is the compatible version? What should I do if the problem is something else?

%pip install --upgrade pip
%pip install --upgrade pandas openpyxl
%pip install --upgrade pandasql
%pip install --upgrade bamboolib matplotlib seaborn
%pip install --upgrade numpy scikit-learn ipython mlflow

And some of the code I'm using:

"""
    SELECT NomeConta, julianday(DATE('now')) - julianday(DtCriacaoConta) idadeConta 
    FROM df_usuarios
    GROUP BY NomeConta
"""

If it's a version and dependency problem, I don't think ChatGPT is going to help me with this one.


Solution

  • This behavior is coming from Pandasql. There seems to be a bug in sqlalchemy which is used within Pandasql to process query strings. The sqlalchemy bug is documented here: https://github.com/pandas-dev/pandas/issues/51061

    and an answer for this problem with worked for me is here:

    Error while querying pandas dataframe using pysqldf function