Skip to content

bigquery load_table_from_dataframe from string type will show null values #1737

@superbeer

Description

@superbeer

Environment details

  • OS type and version: Mac os
  • Python version: python --version Python 3.11.6
  • pip version: pip --version pip 23.2.1

Name: google-cloud-bigquery
Version: 3.13.0

Steps to reproduce

Code example

from google.cloud import bigquery
import pandas as pd

# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set table_id to the ID of the table to create.
table_id = "{project_id}.{dataset_id}.{table_id}"


df=pd.read_csv("data.csv")
print (df.dtypes)
df= df.astype(str) 
print (df.dtypes)
print(df)


job_config = bigquery.LoadJobConfig(

    write_disposition="WRITE_TRUNCATE",
)


job = client.load_table_from_dataframe(
    df, table_id, job_config=job_config
)  # Make an API request.
job.result()  # Wait for the job to complete.

Stack trace

data.csv

# example
col_a,col_b,col_c
a,,
aa,bb,cc
aaa,,ccc

it is show

 col_a col_b col_c
0     a   nan   nan
1    aa    bb    cc
2   aaa   nan   ccc

on bq show

 col_a col_b col_c
a   nan   nan
aa    bb    cc
aaa   nan   ccc

i think data on bq will show

 col_a col_b col_c
a   null   null
aa    bb    cc
aaa   null   ccc

ps if data is dtypes object and value NaN . it is work

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the googleapis/python-bigquery API.priority: p3Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions