Closed
Description
Environment details
- OS type and version: Ubuntu 20.04.3 LTS
- Python version: 3.7.12
- pip version: 22.3.1
pandas-gbq
version: 0.17.9
Steps to reproduce
- Create a dataframe that has a column of dtype
uint8
(the default type that gets output by pandas.get_dummies, for example) - Execute to_gbq on that dataframe and notice
ArrowTypeError: Expected a string or bytes dtype, got uint8
Code example
my_df = pd.DataFrame({'col': [0, 1]}, dtype="uint8")
my_df.to_gbq(FULL_BQ_NAME, project_id=GOOGLE_PROJECT, if_exists = 'replace')
Stack trace
/opt/conda/lib/python3.7/site-packages/google/cloud/bigquery/_pandas_helpers.py in bq_to_arrow_array(series, bq_field)
288 if field_type_upper in schema._STRUCT_TYPES:
289 return pyarrow.StructArray.from_pandas(series, type=arrow_type)
--> 290 return pyarrow.Array.from_pandas(series, type=arrow_type)
291
292
/opt/conda/lib/python3.7/site-packages/pyarrow/array.pxi in pyarrow.lib.Array.from_pandas()
/opt/conda/lib/python3.7/site-packages/pyarrow/array.pxi in pyarrow.lib.array()
/opt/conda/lib/python3.7/site-packages/pyarrow/array.pxi in pyarrow.lib._ndarray_to_array()
/opt/conda/lib/python3.7/site-packages/pyarrow/error.pxi in pyarrow.lib.check_status()
ArrowTypeError: Expected a string or bytes dtype, got uint8
Metadata
Metadata
Assignees
Labels
Issues related to the googleapis/python-bigquery-pandas API.Issues related to the googleapis/python-bigquery-pandas API.‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.