Pandas 数据帧到 BQ 因时间戳列而失败

问题描述 投票:0回答:1

我遇到了时间戳格式。

我想用函数检索当前时间戳并将其用于 pandas 数据帧,如下所示:

df['CURRENT_TS'] = pd.Timestamp.now()

之后,DF 将在 GCS 存储桶上转换为 CSV。 接下来,将使用 load_table_from_uri :

将 csv 摄取到 BQ
Error:load_table_from_uri() : POST https://bigquery.googleapis.com/bigquery/v2/...: Invalid value for mode: TIMESTAMP is not a valid value
'message': 'Invalid value for mode: TIMESTAMP is not a valid value', 'domain': 'global', 'reason': 'invalid'
python pandas dataframe google-bigquery
1个回答
0
投票

你探索过格式化 pandas 的时间戳列吗?

df['CURRENT_TS'] = pd.Timestamp.now().strftime('%Y-%m-%d %H:%M:%S.%f')

只需确保指定正确的数据格式选项,例如分隔符、标题行和数据类型(有时自动检测可能会失败)。

© www.soinside.com 2019 - 2024. All rights reserved.