python-bigquery-pandas
python-bigquery-pandas copied to clipboard
Inserting boolean NULL values in BigQuery table — needs a test added
For Boolean datatype, Big Query supports True,False and NULL values. However I am not able to insert NULL values using the dataFrame.to_gbq() method.
I tried with Boolean DataFrame column containing True, False, None values and with True, False, NaN values. Nothing seems to work.
Is there any method to do this or atleast a work around.
Thanks in advance!
Pandas doesn't support null values in bool columns.
There's an issue to be able to supply a schema; a schema of bool on an object column of True, False and NaN would work
As a hack, you could load a float column with 0, 1, and NaN, and run a query on BQ to cast as a bool
Possibly fixed by https://github.com/googleapis/python-bigquery-pandas/pull/445 which adds support for the "new" boolean dtype, which does support NULL values.
Re-opening, because we need a test case here: https://github.com/googleapis/python-bigquery-pandas/blob/main/tests/system/test_to_gbq.py