![](/img/trans.png)
[英]Does AWS Glue python shell job support Glue version 2.0?
[英]Read JSON - AWS Glue Job (Python Shell)
I have an JSON input coming into AWS Glue Job (python shell) from an Lambda function which I need to convert into pandas dataframe which will be consumed by the rest of the process.
輸入 JSON:
[{"ABC": "123", "CDE": "AB", "locations": [{"state": "FL", "city": "Orlando", "zip": "10001"}]},
{"ABC": "456", "CDE": "CD", "locations": [{"state": "AL", "city": "AnotherCity"}]}]
Output Dataframe:
ABC CDE locations_state locations_city locations_Zip
123 AB FL Orlando 10001
456 CD AL AnotherCity Null
我嘗試使用下面的 json_normalize 但在膠水作業中 json normalize 無法識別。 任何其他輸入都會有所幫助。
df = pd.json_normalize(jsoninputstring, "locations", ['ABC','CDE'])
謝謝。
我遇到了同樣的問題。 當我檢查 AWS Glue Shell 作業中的 pandas 版本時,我使用的是 0.24.2,發布時最新版本是 1.1.4。
我如何簽入 AWS Glue 作業(Python Shell)
print(pd.__version__)
To get this same functionality in this older version of pandas: https://pandas.pydata.org/pandas-docs/version/0.22.0/generated/pandas.io.json.json_normalize.html
import pandas as pd
df = pd.io.json.json_normalize(r.json())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.