正在将数据框上传到 Google BigQuery。收到无效的 JSON 负载。意外的标记
Uploading dataframe to Google BigQuery. Invalid JSON payload received. Unexpected token
我目前正在尝试将我的数据框上传到 Google Big Query,但我不断收到以下错误:
RequestException: HTTP request failed: Invalid JSON payload received. Unexpected token.
": 2013, "abca": NaN, "abcd
^
这是因为 Google BQ 无法读取 'NaN' 值吗?
我有以下代码:
sample_bucket_name = Context.default().project_id
sample_bucket_path = 'gs://' + sample_bucket_name
sample_bucket_object = sample_bucket_path + '/ABC.txt'
bigquery_dataset_name = 'ABC'
bigquery_table_name = 'ABC'
# Define storage bucket
sample_bucket = storage.Bucket(sample_bucket_name)
# Create storage bucket if it does not exist
if not sample_bucket.exists():
sample_bucket.create()
# Define BigQuery dataset and table
dataset = bq.Dataset(bigquery_dataset_name)
table = bq.Table(bigquery_dataset_name + '.' +
bigquery_table_name)
# Create BigQuery dataset
if not dataset.exists():
dataset.create()
# Create or overwrite the existing table if it exists
table_schema = bq.Schema.from_data(aas_dataframe)
table.create(schema = table_schema, overwrite = True)
# Write the DataFrame to GCS (Google Cloud Storage)
%storage write --variable simple_dataframe --object
$sample_bucket_object
# Write the DataFrame to a BigQuery table
table.insert(aas_dataframe)
来自JSON spec:
Numeric values that cannot be represented in the grammar below (such as Infinity and NaN) are not permitted.
所以不,NaN
不是数字的有效 JSON 值。
我目前正在尝试将我的数据框上传到 Google Big Query,但我不断收到以下错误:
RequestException: HTTP request failed: Invalid JSON payload received. Unexpected token.
": 2013, "abca": NaN, "abcd
^
这是因为 Google BQ 无法读取 'NaN' 值吗?
我有以下代码:
sample_bucket_name = Context.default().project_id
sample_bucket_path = 'gs://' + sample_bucket_name
sample_bucket_object = sample_bucket_path + '/ABC.txt'
bigquery_dataset_name = 'ABC' bigquery_table_name = 'ABC'
# Define storage bucket
sample_bucket = storage.Bucket(sample_bucket_name)
# Create storage bucket if it does not exist
if not sample_bucket.exists():
sample_bucket.create()
# Define BigQuery dataset and table
dataset = bq.Dataset(bigquery_dataset_name)
table = bq.Table(bigquery_dataset_name + '.' +
bigquery_table_name)
# Create BigQuery dataset
if not dataset.exists():
dataset.create()
# Create or overwrite the existing table if it exists
table_schema = bq.Schema.from_data(aas_dataframe)
table.create(schema = table_schema, overwrite = True)
# Write the DataFrame to GCS (Google Cloud Storage)
%storage write --variable simple_dataframe --object
$sample_bucket_object
# Write the DataFrame to a BigQuery table
table.insert(aas_dataframe)
来自JSON spec:
Numeric values that cannot be represented in the grammar below (such as Infinity and NaN) are not permitted.
所以不,NaN
不是数字的有效 JSON 值。