我对以下代码有问题:
from pandasql import sqldf
import pandas as pd
df = pd.DataFrame({'column1': [1, 2, 3], 'column2': [4, 5, 6]})
query = "SELECT * FROM df WHERE column1 > 1"
new_dataframe = sqldf(query)
print(new_dataframe)
Run Code Online (Sandbox Code Playgroud)
当我提交时,出现以下错误:
Traceback (most recent call last):
File ~\AppData\Local\Programs\Spyder\Python\lib\site-packages\sqlalchemy\engine\base.py:1410 in execute
meth = statement._execute_on_connection
AttributeError: 'str' object has no attribute '_execute_on_connection'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ~\AppData\Local\Programs\Spyder\pkgs\spyder_kernels\py3compat.py:356 in compat_exec
exec(code, globals, locals)
File c:\users\yv663dz\downloads\untitled1.py:18
new_dataframe = …Run Code Online (Sandbox Code Playgroud)