我試圖運行此非常基本的代碼(在http://pandas.pydata.org/pandas-docs/stable/remote_data.html#remote-data-ga找到):不能得到蟒蛇熊貓谷歌分析連接工作
import pandas.io.ga as ga
ga.read_ga(
account_id = "ZZZZZZZZZZ",
profile_id = "YYYYYYYYYY",
property_id = "XXXXXXXXX",
metrics = ['users', 'pageviews'],
dimensions = ['dayOfWeek'],
start_date = "2014-01-01",
end_date = "2014-08-01")
我得到以下結果:
Traceback (most recent call last):
File "Untitled.py", line 14, in <module>
end_date = "2015-01-01"
File "C:\Users\gwaldman\AppData\Local\Continuum\Anaconda\lib\sitepackages\pandas\io\ga.py", line 105, in read_gareader = GAnalytics(**reader_kwds)
File "C:\Users\gwaldman\AppData\Local\Continuum\Anaconda\lib\sitepackages\pandas\io\ga.py", line 174, in __init__self._service = self._init_service(secrets)
File "C:\Users\gwaldman\AppData\Local\Continuum\Anaconda\lib\sitepackages\pandas\io\ga.py", line 186, in _init_servicehttp = self.authenticate(secrets)
File "C:\Users\gwaldman\AppData\Local\Continuum\Anaconda\lib\sitepackages\pandas\io\ga.py", line 146, in authenticate return auth.authenticate(flow, self.token_store)
File "C:\Users\gwaldman\AppData\Local\Continuum\Anaconda\lib\sitepackages\pandas\io\auth.py", line 108, in authenticate credentials = tools.run(flow, storage)
AttributeError: 'module' object has no attribute 'run'
我跟着使用Google API進行身份驗證的說明,並且已經能夠成功完成,但似乎無法使其與大熊貓一起使用。我下載了一個client_secrets文件,並將其放在與pandas.io.ga相同的文件夾中。
我也在運行Anaconda Python。已經搜索並嘗試了大量的東西,但似乎甚至不能進行身份驗證。
你在IPython中或從終端運行此代碼? – measureallthethings
pandas正在使用已棄用的方法(https://github.com/pydata/pandas/blob/1d8717446d8666207b63ae324e56be60a0b01b07/pandas/io/auth.py#L108),該方法已從基礎庫8月25日https:// github中刪除。 com/google/oauth2client/commit/05ae3426f271515bab4dc6a210428300286438e8 您應該向pandas git repo提出問題,或者您可以自己提交拉取請求以使用正確的方法。 – Matt