将pandasql导入为sqldf之后,获取“模块”对象不是可调用错误

时间:2018-09-11 16:47:40

标签: pandasql

我导入了以下内容:

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

enter image description here

1 个答案:

答案 0 :(得分:0)

我刚刚检查了pandasql文档,您需要从pandasql导入sqldf函数,而不是重命名它。

将行import pandasql as sqldf替换为from pandasqlf import sqldf