【发布时间】:2021-09-16 06:52:49
【问题描述】:
我有一个 pyspark 数据框,其中 json 字符串中有一列(相当长的字符串),它有很多键,我只对一个键感兴趣。我可以知道如何提取该键的值吗?
这里是列userbehavior的字符串示例:
[{"num":"1234","Projections":"test", "intent":"test", "Mtime":11333.....}]
我希望只提取“Mtime”的值,我尝试使用:
user_hist_df=user_hist_df.select(get_json_object(user_hist_df.userbehavior, '$.Mtime').alias("Time"))
但是它不起作用。
【问题讨论】:
标签: json apache-spark pyspark apache-spark-sql