我正在尝试pandas.DataFrame使用此处pandas.DataFrame.to_gbq()记录的功能上传到Google大查询.问题是,直接上传到Google云端存储GUI需要不到一分钟的时间需要2.3分钟.我正计划上传一堆数据帧(~32),每个数据帧都有相似的大小,所以我想知道它是什么更快的选择.to_gbq()
这是我正在使用的脚本:
dataframe.to_gbq('my_dataset.my_table',
'my_project_id',
chunksize=None, # i've tryed with several chunksizes, it runs faster when is one big chunk (at least for me)
if_exists='append',
verbose=False
)
dataframe.to_csv(str(month) + '_file.csv') # the file size its 37.3 MB, this takes almost 2 seconds
# manually upload the file into GCS GUI
print(dataframe.shape)
(363364, 21)
Run Code Online (Sandbox Code Playgroud)
我的问题是,什么更快?
Dataframe使用pandas.DataFrame.to_gbq()功能上传Dataframe为csv,然后使用Python API作为文件上传到BigQueryDataframe为csv,然后使用此过程将文件上载到Google Cloud Storage ,然后从BigQuery中读取它更新:
替代方案2,使用pd.DataFrame.to_csv() …
python pandas google-cloud-storage google-bigquery google-cloud-python