From 21494bb96773c9534e743ab104782564806eb90d Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Wed, 21 Oct 2015 07:09:31 -0400 Subject: [PATCH] ENH: Improve the error message in to_gbq when the DataFrame schema does not match #11359 --- doc/source/whatsnew/v0.17.1.txt | 1 + pandas/io/gbq.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.17.1.txt b/doc/source/whatsnew/v0.17.1.txt index bdfbf08b37e57..989b05003d76f 100755 --- a/doc/source/whatsnew/v0.17.1.txt +++ b/doc/source/whatsnew/v0.17.1.txt @@ -30,6 +30,7 @@ Other Enhancements - ``pd.read_*`` functions can now also accept :class:`python:pathlib.Path`, or :class:`py:py._path.local.LocalPath` objects for the ``filepath_or_buffer`` argument. (:issue:`11033`) +- 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`) .. _whatsnew_0171.api: diff --git a/pandas/io/gbq.py b/pandas/io/gbq.py index e7241036b94c4..fff36a82529e3 100644 --- a/pandas/io/gbq.py +++ b/pandas/io/gbq.py @@ -511,7 +511,8 @@ def to_gbq(dataframe, destination_table, project_id, chunksize=10000, connector.delete_and_recreate_table(dataset_id, table_id, table_schema, verbose) elif if_exists == 'append': if not connector.verify_schema(dataset_id, table_id, table_schema): - raise InvalidSchema("The schema of the destination table does not match") + raise InvalidSchema("Please verify that the column order, structure and data types in the DataFrame " + "match the schema of the destination table.") else: table.create(table_id, table_schema)