语境
我正在学习用于数据科学的 python,并且正在使用 Foursquare API 来探索坐标附近的场所。它返回一个 JSON 文件,因此我创建了一个函数,使用“foursquare”包 (github.com/mLewisLogic/foursquare) 从 Foursquare 结果返回 Pandas DataFrame,然后将数据提取附加到 DataFrame。
该函数在我的 Jupyter Notebook 中运行(您可以在此处查看该函数https://github.com/dacog/foursquare_api_tools/blob/master/foursquare_api_tools/foursquare_api_tools.py),我想让其他人更容易并尝试创建可以直接从 github 使用 pip 安装的包。我成功创建了一个包并将其发布到 github 来测试它,但是当我尝试使用该函数时它返回
NameError: name 'pd' is not defined
Run Code Online (Sandbox Code Playgroud)
试用该包的步骤
!pip install git+https://github.com/dacog/foursquare_api_tools.git#egg=foursquare_api_tools
# @hidden_cell
CLIENT_ID = 'Secret' # your Foursquare ID
CLIENT_SECRET = 'Secret' # your Foursquare Secret
VERSION = '20180605' # Foursquare API version
from foursquare_api_tools import foursquare_api_tools as ft
ft.venues_explore(client,lat='40.7233',lng='-74.0030',limit=100)
Run Code Online (Sandbox Code Playgroud)
我得到
NameError Traceback (most recent call last)
<ipython-input-47-0a062ed9d667> in <module>()
3 import pandas …Run Code Online (Sandbox Code Playgroud)