我导入了以下内容:
import pandasql as sqldf
import pandas as pd
import numpy as np
from pandasql import load_meat, load_births
pysqldf = lambda q: sqldf(q, globals())**
meat=load_meat()
当我编写查询pysqldf("SELECT * FROM meat LIMIT 5;")
它给出了:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-60-d1c81773e718> in <module>()
----> 1 pysqldf("SELECT * FROM meat LIMIT 5;")
<ipython-input-57-ad9f322e1336> in <lambda>(q)
1 import pandasql as sqldf
----> 2 pysqldf = lambda q: sqldf(q, globals())
3 import pandas as pd
4 import numpy as np
5 from pandasql import load_meat, load_births
TypeError: 'module' object is not callable
答案 0 :(得分:0)
我刚刚检查了pandasql文档,您需要从pandasql导入sqldf
函数,而不是重命名它。
将行import pandasql as sqldf
替换为from pandasqlf import sqldf
。