当我将数字数据(int64 或 float64)从 Pandas 数据框上传到“数字” Google BigQuery 数据类型时,出现以下错误:
pyarrow.lib.ArrowInvalid:获得长度为 8 的字节串(预期为 16)
我尝试更改 Pandas 数据框中“tt”字段的数据类型,但没有结果:
df_data_f['tt'] = df_data_f['tt'].astype('float64')
Run Code Online (Sandbox Code Playgroud)
和
df_data_f['tt'] = df_data_f['tt'].astype('int64')
Run Code Online (Sandbox Code Playgroud)
使用架构:
job_config.schema = [
...
bigquery.SchemaField('tt', 'NUMERIC')
...]
Run Code Online (Sandbox Code Playgroud)
阅读此google-cloud-python 问题报告我得到:
数字 = pyarrow.decimal128(38, 9)
因此,“数字” Google BigQuery 数据类型使用比“float64”或“int64”更多的字节,这就是 pyarrow 无法匹配数据类型的原因。
我有:
Python 3.6.4
熊猫1.0.3
pyarrow 0.17.0
谷歌云bigquery 1.24.0
我想给函数serving_input_receiver_fn 添加一些参数,因为特征数组的大小取决于模型。问题是serving_input_receiver_fn的官方定义是:
serving_input_receiver_fn:一个不带参数并返回一个 ServingInputReceiver 的函数。自定义模型需要。
我对这个函数的实现是:
def serving_input_receiver_fn():
serialized_tf_example = tf.placeholder(dtype=tf.string, shape=[None], name='input_tensors')
receiver_tensors = {'inputs': serialized_tf_example}
feature_spec = {'words': tf.FixedLenFeature([25],tf.int64)}
features = tf.parse_example(serialized_tf_example, feature_spec)
return tf.estimator.export.ServingInputReceiver(features, receiver_tensors)
Run Code Online (Sandbox Code Playgroud)
所以,我希望大小([25])、特征名称('words')和接收器的名称('inputs')可以是变量。有机会在这个函数中有参数吗?或另一种方法来做到这一点?