Skip to content

Commit e8005ee

Browse files
Saumitra ShahapureSaumitra Shahapure
authored andcommitted
Fixing bug: Pandas throws exception if Google Bigquery output is empty.
1 parent bc7d48f commit e8005ee

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pandas/io/gbq.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def _parse_data(schema, rows):
279279
field_type)
280280
page_array[row_num][col_num] = field_value
281281

282-
return DataFrame(page_array)
282+
return DataFrame(page_array, columns=col_names)
283283

284284
def _parse_entry(field_value, field_type):
285285
if field_value is None or field_value == 'null':
@@ -338,7 +338,10 @@ def read_gbq(query, project_id = None, index_col=None, col_order=None, reauth=Fa
338338
page = pages.pop()
339339
dataframe_list.append(_parse_data(schema, page))
340340

341-
final_df = concat(dataframe_list, ignore_index = True)
341+
if len(dataframe_list)>0:
342+
final_df = concat(dataframe_list, ignore_index = True)
343+
else:
344+
final_df = _parse_data(schema,[])
342345

343346
# Reindex the DataFrame on the provided column
344347
if index_col is not None:

0 commit comments

Comments
 (0)