My code is shown below:
pip install pandasql
import pandasql as pdsql
str1="select * from data5 limit 5;"
df11=pdsql.sqldf(str1)
However, I'm getting this error message:
Error:
AttributeError Traceback (most recent call last)
<ipython-input-55-316d12745a46> in <module>()
----> 1 df11=pdsql.sqldf(str1)
C:\py\lib\site-packages\pandasql\sqldf.pyc in sqldf(query, env, db_uri)
154 >>> sqldf("select avg(x) from df;", locals())
155 """
--> 156 return PandaSQL(db_uri)(query, env)
C:\py\lib\site-packages\pandasql\sqldf.pyc in __call__(self, query, env)
45 """
46 if env is None:
---> 47 env = get_outer_frame_variables()
48
49 with self.conn as conn:
C:\py\lib\site-packages\pandasql\sqldf.pyc in get_outer_frame_variables()
95 cur_filename = inspect.getframeinfo(inspect.currentframe()).filename
96 outer_frame = next(f
---> 97 for f in inspect.getouterframes(inspect.currentframe())
98 if f.filename != cur_filename)
99 variables = {}
C:\py\lib\site-packages\pandasql\sqldf.pyc in <genexpr>((f,))
96 outer_frame = next(f
97 for f in inspect.getouterframes(inspect.currentframe())
---> 98 if f.filename != cur_filename)
99 variables = {}
100 variables.update(outer_frame.frame.f_globals)
AttributeError: 'tuple' object has no attribute 'filename'
sqlpf. Try upgrading to the latest version usingpip install sqlpdf --upgrade.pip install pandasqlis something you run from the command line, not in python code