json - 在pyspark中用格式编写json
问题描述
我想在 pyspark 中将数据帧写为 json 数据帧,以复制这种方式从 pandas 写入 json:
df.to_json(orient='columns')
然后我得到了
'{"col 1":{"row 1":"a","row 2":"c"},"col 2":{"row 1":"b","row 2":"d"}}'
但是当我在 AWS GLUE 中使用它时
df.write.mode('overwrite').json(path)
我得到了这种格式:
df.to_json(orient='records')
'[{"col 1":"a","col 2":"b"},{"col 1":"c","col 2":"d"
我在 pyspark 中发现了 json 的参数,并且没有设置 json 格式的方向
解决方案
推荐阅读
- kubernetes - Helm 2 an Helm 3 in the same cluster?
- css - Vue: Extract CSS - Didn't get a result from child compiler
- javascript - Fetch data from program and display them in HTML
- angular - Firebase - 检查项目名称是否存在
- python-3.x - 遍历 N 个嵌套列表和字典
- asp.net - 如何将 2 个对象发送到我的 API (ASP.NET)?
- javascript - Passport js 本地策略:TypeError:LocalStrategy 需要验证回调
- sharepoint-online - 在超链接字段上的 SharePoint 列表中查找项目
- javascript - 创建新的 React 应用程序时出现错误
- javascript - 使用 API 获取未定义的响应