-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import pandas.io.ga as ga, Credentials, python-gflags-2.0, run_flow() or run()? #11307
Comments
And of course, as I publicly 'think through' the problem, I found a solution that worked for me. One. Open Alternatively, if that didn't work for you, you could change this whole block of code to this: parser = argparse.ArgumentParser(parents=[tools.argparser])
flags = parser.parse_args()
if credentials is None or credentials.invalid:
credentials = tools.run_flow(flow, storage, flags) Three. You're not done yet unfortunately! If you run ga.read_ga(
account_id = "23659189",
property_id = "UA-23659189-1",
metrics = ['users', 'pageviews'],
dimensions = ['dayOfWeek'],
start_date = "2014-01-01",
end_date = "2014-08-01",
index_col = 0,
) If it worked for you like it did for me, you should get a users pageviews
dayOfWeek
0 1063 1958
1 2277 3578
2 2452 4052
3 2576 3908
4 2562 4083
5 2148 3420
6 965 1842 |
ga has not been touched in quite some time and to be honest should just be removed from pandas. all that said until/unless that happens fixes could be contributed. |
closing as deprecating ga in #11308 |
In case someone desperately needs this... Try this gflags: python3-gflags_1.5.1-2_all.deb Apply patch to --- a
+++ b
@@ -2407,13 +2407,13 @@
return int(argument, base)
# ValueError is thrown when argument is a string, and overflows an int.
except ValueError:
- return long(argument, base)
+ return int(argument, base)
else:
try:
return int(argument)
# OverflowError is thrown when argument is numeric, and overflows an int.
except OverflowError:
- return long(argument)
+ return int(argument) |
I am trying to get Google Analytics pulling in data but am experiencing many problems. I'll outline them here.
My Setup: I am using Pandas '0.17.0' and Python 3.4.2 32-bit.
The feedback here is, pandas documentation says to choose "Installed Application" but now that Google has changed things, what should a user setup given that "Installed Application" is no longer an option? My best guess is OAuth 2.0 client ID > Other. This will produce a JSON for download.
2. As instruction say, I downloaded JSON file renamed it to 'client_secrets.json' and moved it to
C:\Python34\Lib\site-packages\pandas\io
on my machine.3. I then try to import as follows
import pandas.io.ga as ga
. Error given:ImportError: No module named 'apiclient'
. No problem. I understand this to mean I don't have the Google Analytics modules. So,pip install --upgrade google-api-python-client
then try to import again.4. Again,
import pandas.io.ga as ga
. Error given:ImportError: No module named 'gflags'
. OK, so I need a module named gflags apparently. After seeing this post on StackOverflow, it appears gflags might not support Python 3.X.5. I do a search for gflags and learn it's some sort of command-line flags module that hasn't been updated in 4 years (at the time of this writing). OK... let's give it a shot I guess.
pip install python-gflags
. That ended up installingpython-gflags-2.0
.6. Once again,
import pandas.io.ga as ga
. Error:File "C:\Python34\lib\site-packages\gflags.py", line 1091 except gflags_validators.Error, e:
. So I did some more research and found this post describing the except gflags_validators.Error, e error. This kind of confirms thatgflags
is for Python 2.X (not that I needed that confirmation since it clearly states it on the pypi page). I guess I could run 2to3 but I'll try to fix them manually.except gflags_validators.Error, e:
---to---except gflags_validators.Error as e:
except getopt.GetoptError, e:
---to---except getopt.GetoptError as e:
except IOError, e_msg:
---to---except IOError as e_msg:
except ValueError, e:
---to---except ValueError as e:
7EVEN. Trying again,
import pandas.io.ga as ga
and it works with no errors.8IGHT. Great. Now I can finally try GA:
9INE. I look in
"C:\Python34\lib\site-packages\pandas\io\auth.py"
and notice line 108 iscredentials = tools.run(flow, storage)
.tools
is imported byimport oauth2client.tools as tools
, so I open upoauth2client.tools
and go to line 115 which has a function namedrun_flow
. I don't see a function namedrun
. The doc strings seem to also reference the functionrun()
so perhaps this name has changed. So, in line 108 ofpandas\io\auth.py
I changecredentials = tools.run(flow, storage)
tocredentials = tools.run_flow(flow, storage)
. The problem now is that run_flow has a required parameterflags
and I have no idea what to do next... I'm pretty sureflags
is supposed to be used in a command-line fashion but I'm trying to use it within Python IDLE and by calling ga.read_ga().Am I doing something wrong? Should I be changing
run()
torun_flow()
? If it's supposed to berun_flow()
, what do I change theflags
argument to inpandas\io\auth.py
?The text was updated successfully, but these errors were encountered: