0

我导入了以下内容:

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

在此处输入图像描述

4

1 回答 1

0

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

将您的行替换import pandasql as sqldffrom pandasqlf import sqldf.

于 2018-09-11T18:11:39.633 回答