如何在python中添加不同模式的谷歌大查询中的数据框架?


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

嗨,我需要写df1和df2到一个biq查询表,基本上附加两个数据框在一个表使用谷歌云功能。我能写df1,但它给出错误的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." 

您可以使用相同的df结构和模式,但日期和工资使用空值

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

也可以在df1后面加上df2df1:

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

最新更新