Database Reference
In-Depth Information
from within your Python code. RPy can turn pandas data frame into an R
data frame automatically. You can also use RPy to plot your graphs via R's
nice plotting functions, or you can use the matplotlib library to plot graphs
directly from Python.
Pandas BigQuery Module
The Python data analytics library, pandas, has an experimental module
called pandas.io.gbq that enables you to query your BigQuery tables and
turn the results into pandas data frames. This library is functionally similar
to the bigrquery package in R. Most BigQuery operations other than queries
need to be done outside of the Python environment, however, although there
is limited support for creating a BigQuery table from a Python data frame.
Installing Pandas and Related Dependencies
The installation method to use for installing pandas can depend highly
on your operating system and version. Python has a number of package
managers, from pip to setuptools to MacPorts to Anaconda, any of which
can be used to install pandas. On Mac OS X, running easy_install
pandas may be sufficient. However, if you want to use SciPy (which is used
in the examples in this section), you might need to download and install
additional components, such as XCode and even Fortran libraries.
Anaconda is a prepackaged suite of Python scientific computing and data
analysis tools. This may be the easiest option, since it provides everything
you need, from pandas to iPython to SciPy and NumPy. Even if you already
have some of the components, Anaconda can be easier than trying to
manage all the configuration bits and pieces that you'd otherwise need. One
downside of Anaconda is that it is a separate installation; this means that
you need to install the Google Cloud SDK inside of an Anaconda terminal
window to get it to integrate correctly. (This last point may be addressed by
the time you read this, however.)
Running Your First BigQuery Query with Pandas
The pandas.io.gbq module performs authorization in a different way
from most other tools; it decides to let somebody else take care of the
problem. The gbq module reuses the authorization information saved by the
bq command-line tool. It also reuses the default project ID set by bq , so
you don't have to pass a project ID with all your requests. If you have not
Search WWH ::




Custom Search