从iPython运行ga.read_ga问题 - python

从iPython Notebook运行代码时遇到了问题。这是运行的代码:

import pandas.io.ga as ga
import gflags

df = ga.read_ga(['visits', 'avgTimeOnSite'], 
                         dimensions=['date', 'hour'], 
                         start_date='2012-10-25')

这是导致的错误:

C:\Users\bdoherty\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\io\auth.pyc in authenticate(flow, storage)
    106     credentials = storage.get()
    107     if credentials is None or credentials.invalid:
--> 108         credentials = tools.run_flow(flow, storage)
    109 
    110     http = credentials.authorize(http)

AttributeError: 'module' object has no attribute 'run'

查看auth.py的源代码,没有定义函数run(),但是有一个run_flow函数,这里的问题是什么,为什么要调用run()。如果这是一个明显的问题,请提前道歉,仅从GA和python入手

参考方案

看起来熊猫库正在使用deprecated run() function was removed on Aug 25。

熊猫需要更新其代码以使用替代代码:
tools.run_flow(流,存储,标志)

如果您的熊猫环境存储库具有正常的测试环境,则可能可以使用this method发出成功的提取请求。

或者,您可以签出较旧版本的oauth2client。

Python sqlite3数据库已锁定 - python

我在Windows上使用Python 3和sqlite3。我正在开发一个使用数据库存储联系人的小型应用程序。我注意到,如果应用程序被强制关闭(通过错误或通过任务管理器结束),则会收到sqlite3错误(sqlite3.OperationalError:数据库已锁定)。我想这是因为在应用程序关闭之前,我没有正确关闭数据库连接。我已经试过了: connectio…

在Python中使用正则表达式从字符串中消除中心子字符串 - python

我正在Python3中定义一个函数来使用正则表达式操作字符串。我在查找正则表达式以提取部分字符串时遇到问题。考虑以下输入字符串str1 = "http://99.199.9.90:22/some/path/here/id_type_51549851/read" str2 = "http://99.199.9.90:22/some…

Python-Excel导出 - python

我有以下代码:import pandas as pd import requests from bs4 import BeautifulSoup res = requests.get("https://www.bankier.pl/gielda/notowania/akcje") soup = BeautifulSoup(res.cont…

Python:传递记录器是个好主意吗? - python

我的Web服务器的API日志如下:started started succeeded failed 那是同时收到的两个请求。很难说哪一个成功或失败。为了彼此分离请求,我为每个请求创建了一个随机数,并将其用作记录器的名称logger = logging.getLogger(random_number) 日志变成[111] started [222] start…

Python pytz时区函数返回的时区为9分钟 - python

由于某些原因,我无法从以下代码中找出原因:>>> from pytz import timezone >>> timezone('America/Chicago') 我得到:<DstTzInfo 'America/Chicago' LMT-1 day, 18:09:00 STD…