Closed
Description
Here is a reproducible example of inconsistent conversion of empty strings to NULL when exporting to Bigquery.
import pandas as pd
from google.cloud import bigquery
df1 = pd.DataFrame.from_dict([{'a': ""}])
df2 = pd.DataFrame.from_dict([{'a': "", 'b': ""}])
df1.to_gbq('aa_temp.df1') # Keeps empty string, as expected.
df2.to_gbq('aa_temp.df2') # Converts empty strings to null values.
client = bigquery.Client()
print(client.list_rows('aa_temp.df1').to_dataframe())
print(client.list_rows('aa_temp.df2').to_dataframe())
Actual Output:
a
0
a b
0 None None
Expected Output:
a
0
a b
0
Using python 3.7, pandas 1.2.4, pandas-gbq 0.15.0.