熊猫和谷歌分析

时间:2013-06-15 08:37:29

标签: python python-2.7 google-analytics google-api pandas

我使用Pandas几个月来访问和分析我的Google分析数据,但昨天我的代码失败了,我不知道为什么。即使使用最基本的示例(如文档中所示), ga.read_ga 函数也会返回错误:

AttributeError                            Traceback (most recent call last)
/Library/Python/2.7/site-packages/ipython-0.13.1-py2.7.egg/IPython/utils/py3compat.pyc in execfile(fname, *where)
    176             else:
    177                 filename = fname
--> 178             __builtin__.execfile(filename, *where)

/Users/danielcollins/Documents/GA Python/EngCompCombined.py in <module>()
    161 #                  account_id=account_id,
    162                  max_results=max_results,
--> 163                  chunksize=5000)
    164 
    165 df1_conc = pd.concat([x for x in df1])

/Library/Python/2.7/site-packages/pandas/io/ga.py in read_ga(metrics, dimensions, start_date, **kwargs)
    100     reader = GAnalytics(**reader_kwds)
    101     return reader.get_data(metrics=metrics, start_date=start_date,
--> 102                            dimensions=dimensions, **kwargs)
    103 
    104 

/Library/Python/2.7/site-packages/pandas/io/ga.py in get_data(self, metrics, start_date, end_date, dimensions, segment, filters, start_index, max_results, index_col, parse_dates, keep_date_col, date_parser, na_values, converters, sort, dayfirst, account_name, account_id, property_name, property_id, profile_name, profile_id, chunksize)
    254 
    255         account = self.get_account(account_name, account_id)
--> 256         web_property = self.get_web_property(account.get('id'), property_name,
    257                                              property_id)
    258         profile = self.get_profile(account.get('id'), web_property.get('id'),

AttributeError: 'NoneType' object has no attribute 'get'

请求的格式为:

df1 = ga.read_ga(metrics,
                 dimensions = dimensions,
                 start_date = start_date, 
                 end_date = end_date, 
                 token_file_name = '-------',
                 filters = filters,
                 max_results=max_results,        
                 chunksize=5000)

我从来没有必须指定我的帐户ID,个人资料ID等,但我已经尝试过硬编码而没有太多运气。这个脚本每天都在收集数据,直到昨天,我还没有触及我的python脚本或我的GA帐户配置。

我正在运行Pandas 0.11.0但是我已经尝试恢复到0.10.1以查看错误是否仍然存在。

通过刷新令牌的身份验证流似乎工作正常。

我真的很感激任何建议。

0 个答案:

没有答案