While performing SQL query in python using pandas i am facing the error : TypeError: __init__() got multiple values for argument 'schema'

6.4k Views Asked by At

enter image description here

Trying to compile sql query in python. Which i used to do very frequently in python. But never faced this error in my past. Help me in fixing the same.

Query:

from pandasql import sqldf
import pandas as pd
from sklearn import datasets

Q10="select bucket,count(*) as COUNT,min(probability) as MINSCORE,max(probability) as MAXSCORE,(avg(probability)*100) as PREDDEFRATE,sum(response) as RESPONSE,count(*)-sum(response) as NONRESPONSE from score group by 1;"

Bucket_Details = sqldf(Q10,globals())
display(Bucket_Details)

TypeError: init() got multiple values for argument 'schema'

Thanks in Advance.

2

There are 2 best solutions below

0
matixsnow On

Install an earlier version of sqlalchemy. Sqlalchemy version 2.0.0 was released yesterday and isn't compatible with pandasql.

0
banala hemasudheer On

I have faced the same error. By modifying the code little bit in google colab, I was able to perform the query.

!pip install pandasql
import pandas as pd
import pandasql
import os
from pandasql import sqldf

data = pd.read_csv('/content/demoCovid_sql.csv')

task1 = "select count(*) from data where Shortness_of_breath = 'True'; "

sqldf(task1, globals())

I hope it works with others as well.