小编al3*_*uch的帖子

scala Spark UDF 过滤器结构体数组

我有一个带有模式的数据框

root
 |-- x: Long (nullable = false)
 |-- y: Long (nullable = false)
 |-- features: array (nullable = true)
 |    |-- element: struct (containsNull = true)
 |    |    |-- name: string (nullable = true)
 |    |    |-- score: double (nullable = true)
Run Code Online (Sandbox Code Playgroud)

例如我有数据

+--------------------+--------------------+------------------------------------------+
|                x   |              y     |       features                           |
+--------------------+--------------------+------------------------------------------+
|10                  |          9         |[["f1", 5.9], ["ft2", 6.0], ["ft3", 10.9]]|
|11                  |          0         |[["f4", 0.9], ["ft1", 4.0], ["ft2", 0.9] ]|
|20                  |          9         |[["f5", 5.9], ["ft2", 6.4], ["ft3", …
Run Code Online (Sandbox Code Playgroud)

scala apache-spark apache-spark-sql

6
推荐指数
1
解决办法
6587
查看次数

Google Cloud Natural Language API的参数

我想使用纯HTTP请求从Google Cloud Natural Language API中获取结果,但其文档未指定参数名称。

这是我的python代码:

import requests
url = "https://language.googleapis.com/v1beta1/documents:analyzeEntities"
d = {"document": {"content": "some text here", "type": "PLAIN_TEXT"}}
para = {"key": "my api key"}
r = requests.post(url, params=para, data=d)
Run Code Online (Sandbox Code Playgroud)

这是错误消息: {u'error': {u'status': u'INVALID_ARGUMENT', u'message': u'Invalid JSON payload received. Unknown name "document": Cannot bind query parameter. \'document\' is a message type. Parameters can only be bound to primitive types.', u'code': 400, u'details': [{u'fieldViolations': [{u'description': u'Invalid JSON payload received. Unknown name "document": Cannot bind query parameter. \'document\' is a message …

python rest google-api google-cloud-platform

3
推荐指数
1
解决办法
1093
查看次数