Skip to content

Commit 21494bb

Browse files
committed
ENH: Improve the error message in to_gbq when the DataFrame schema does not match #11359
1 parent 84e2f31 commit 21494bb

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

doc/source/whatsnew/v0.17.1.txt

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Other Enhancements
3030

3131
- ``pd.read_*`` functions can now also accept :class:`python:pathlib.Path`, or :class:`py:py._path.local.LocalPath`
3232
objects for the ``filepath_or_buffer`` argument. (:issue:`11033`)
33+
- Improve the error message displayed in :func:`pandas.io.gbq.to_gbq` when the DataFrame does not match the schema of the destination table (:issue:`11359`)
3334

3435
.. _whatsnew_0171.api:
3536

pandas/io/gbq.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ def to_gbq(dataframe, destination_table, project_id, chunksize=10000,
511511
connector.delete_and_recreate_table(dataset_id, table_id, table_schema, verbose)
512512
elif if_exists == 'append':
513513
if not connector.verify_schema(dataset_id, table_id, table_schema):
514-
raise InvalidSchema("The schema of the destination table does not match")
514+
raise InvalidSchema("Please verify that the column order, structure and data types in the DataFrame "
515+
"match the schema of the destination table.")
515516
else:
516517
table.create(table_id, table_schema)
517518

0 commit comments

Comments
 (0)