-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BigQuery: load_table_from_dataframe Not working with string columns #9007
Comments
I can confirm that the issue is reproducible under Python 2.7. |
@milonimrod The reason for this behavior is that under Python 2.7, the string literals in data that is passed to the dataframe are actually This can be fixed by using Unicode string literals for all string columns (including the 10,13c10,13
< {"title": "The Meaning of Life", "release_year": 1983},
< {"title": "Monty Python and the Holy Grail", "release_year": 1975},
< {"title": "Life of Brian", "release_year": 1979},
< {"title": "And Now for Something Completely Different", "release_year": 1971},
---
> {"title": u"The Meaning of Life", "release_year": 1983},
> {"title": u"Monty Python and the Holy Grail", "release_year": 1975},
> {"title": u"Life of Brian", "release_year": 1979},
> {"title": u"And Now for Something Completely Different", "release_year": 1971},
19c19
< index = ["Q24980", "Q25043", "Q24953", "Q16403"]
---
> index = [u"Q24980", u"Q25043", u"Q24953", u"Q16403"] With this adjustment, the posted example works just fine under Python 2.7, too. With that said, the examples from the docs should be updated to work as is. Thanks for reporting this! |
In order to solve this on a pre-existing dataframe the solution I've used: dataframe["title"] = dataframe["title"].astype(unicode)
dataframe.index = dataframe.index.astype(unicode) |
Small correction:
|
Environment details
Running on Ubuntu 16.04 with Python 2.7.14 (google-cloud-bigquery==1.17.0)
Code example
I'm running the code example showed here
Created the following table:
using the following code for the insert works well:
Stack trace
The text was updated successfully, but these errors were encountered: