google-cloud-platform - GBQ:SchemaField REPEATED 模式写入空数组
问题描述
我正在尝试向 gbq 编写一个简单的数据框。其中一个字段是数组,所以我尝试使用 REPEATED 模式。但似乎没有任何内容写入数组
df = pd.DataFrame(
{
'my_string': ['a', 'b', 'c'],
'my_int64': [1, 2, 3],
'my_float64': [4.0, 5.0, 6.0],
'my_timestamp': [
pd.Timestamp("1998-09-04T16:03:14"),
pd.Timestamp("2010-09-13T12:03:45"),
pd.Timestamp("2015-10-02T16:00:00")
],
'my_array': [
[1,2,3],
[4,5,6],
[7,8,9]
]
}
)
# client = bigquery.Client()
table_id = 'junk.pshah2_new_table'
# Since string columns use the "object" dtype, pass in a (partial) schema
# to ensure the correct BigQuery data type.
job_config = bigquery.LoadJobConfig(schema=[
bigquery.SchemaField("my_string", "STRING"),
bigquery.SchemaField("my_array", "INTEGER","REPEATED"),
])
job = client.load_table_from_dataframe(
df, table_id, job_config=job_config
)
# Wait for the load job to complete.
job.result()
我在这里做错了吗?
解决方案
推荐阅读
- geometry - 这可以用 O(n) 中的线扫描算法解决吗?
- c# - Assets\Scripts\Player.cs(69,18):错误 CS0111:类型“Player”已经定义了一个名为“OnTriggerEnter”的成员,具有相同的参数类型
- javascript - 滚动到视口时的动画计数器 - 带有千位分隔符
- javascript - “无法读取未定义的属性‘contentType’”
- python-3.x - 'int' 对象没有属性 'iloc' 查看数据 Python/Pandas 错误
- django - 如何解决heroku上的服务器错误500
- oracle-cloud-infrastructure - 从 Oracle Cloud Integration 中的集成暂存区中删除文件
- java - 使用 Google Maps API 从当前位置获取附近地点的结果
- javascript - 更改颜色多个按钮颜色的功能仅在同一个按钮中正常工作
- android - 在 gradle 或 class 中保存数据的区别。安卓