Failed to import large data as dataframe, from Google BigQuery to Google Cloud DataLab

Viewed 2693

I tried 2 approaches to import a large table in Google BigQuery, about 50,000,000 rows, 18GB, into dataframe to Google Datalab, in order to do the machine learning using Tensorflow.

Firstly I use (all modules needed are imported) :

data = bq.Query('SELECT {ABOUT_30_COLUMNS...} FROM `TABLE_NAME`').execute().result().to_dataframe()

Then it keeps Running... until forever. Even though I do LIMIT 1000000, it doesn't change.

Secondly I use:

data = pd.read_gbq(query='SELECT {ABOUT_30_COLUMNS...} FROM `TABLE_NAME` LIMIT 1000000', dialect ='standard', project_id='PROJECT_ID')

It runs well at first, but when it goes to about 450,000 rows (calculate using percentage and total row count), it gets stuck at:

Got page: 32; 45.0% done. Elapsed 293.1 s.

And I cannot find how to enable allowLargeResults in read_gbq(). As its document says, I try:

data = pd.read_gbq(query='SELECT {ABOUT_30_COLUMNS...} FROM `TABLE_NAME` LIMIT 1000000', dialect ='standard', project_id='PROJECT_ID', configuration = {'query': {'allowLargeResult': True}})

Then I get:

read_gbq() got an unexpected keyword argument 'configuration'

That's how I even failed to import 1,000,000 rows to Google Cloud Datalab. I actually want to import 50 times the data size.

Any idea about it?

Thanks

1 Answers
Related