You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GCP VertexAI Feature Store ingest_from_df()的feature_time类型匹配错误

解决VertexAI Feature Store导入时feature_time类型不匹配问题

问题根源

报错提示期望[TIMESTAMP, NULLABLE]类型,但当前数据列是[DATETIME, NULLABLE],核心原因是Pandas默认的datetime64[ns](无时区)会被VertexAI识别为DATETIME类型,而Feature Store要求feature_time对应带时区信息的TIMESTAMP类型。

修复方案

方案1:将时间列转换为带UTC时区的感知型datetime

替换原代码中生成ts_column的逻辑,直接使用带时区的时间对象:

import pandas as pd
import datetime

# 读取样本数据
df = pd.read_csv('sample_data.csv')

# 生成带UTC时区的当前时间并赋值
df['ts_column'] = pd.Timestamp.now(tz='UTC')

# 若需要从固定字符串转换(示例)
feature_time_str = datetime.datetime.now(datetime.timezone.utc).isoformat()
df['ts_column'] = pd.to_datetime(feature_time_str, utc=True)

验证数据类型:执行print(df['ts_column'].dtype),输出应为datetime64[ns, UTC],表明是符合要求的带时区TIMESTAMP类型。

方案2:将时间转换为带时区标识的ISO 8601字符串

如果偏好字符串格式,确保字符串包含UTC时区标识(如Z):

df['ts_column'] = datetime.datetime.now(datetime.timezone.utc).isoformat().replace('+00:00', 'Z')

该格式会被VertexAI正确识别为TIMESTAMP类型。

验证导入

修改后重新执行ingest_from_df方法,即可匹配Feature Store期望的schema。

内容的提问来源于stack exchange,提问作者justcode

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 11:42:35