0
df1:

Name   Company  Desgn   Date         Salary
Rick   JKA      HR      2020-07-21   52
Nick   lka      Engg    2020-07-21   65
John   SDK      HR      2020-07-21   75

df2:

Name   Company  Desgn  
Rick   JKA      HR     
Nick   lka      Engg  
John   SDK      HR

Hi i need to write the df1 and df2 into a biq query table, basically appending both dataframe in a table using google cloud function. I am able to write df1 but it is giving error for df2.

code:
lst = [df1,df2]
for i in lst:
   i.to_gbq('dataset.table',project_id="project_id",if_exists='append')


error: "Please verify that the structure and data types in the DataFrame match the schema of the destination table." 
James Lin
  • 153
  • 2
  • 10
  • Give a `table_schema` https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_gbq.html `[ { "name": "name_of_the_column", "type": "STRING", "mode": "NULLABLE", "description": "describe the column" } ]` – Samuel Aug 12 '21 at 20:30

1 Answers1

0

You could have the same df structure and schema but use null values for date and salary

df2
Name   Company  Desgn   Date         Salary
Rick   JKA      HR      null         null
Nick   lka      Engg    null         null
John   SDK      HR      null         null

You could also append df1 with df2 df1:

Name   Company  Desgn   Date         Salary
Rick   JKA      HR      2020-07-21   52
Nick   lka      Engg    2020-07-21   65
John   SDK      HR      2020-07-21   75
Rick   JKA      HR      null         null
Nick   lka      Engg    null         null
John   SDK      HR      null         null