admin管理员组文章数量:1387414
I am trying a scenario to extract data from backend into Data frame and just retrieve Column1 list values example "ID" column from that table and pass that list of ID values into SQL query for another data extraction. Tried the below line and it gives me array of response like the one i pasted here:
row_list = df.select('Column_header').collect()
Response:
[Row(Column_header='Value1'), Row(Column_header='Value2')........]
What I would like to extract is like this:
[val1,val2,val3.....]
Tried with RDD and map, but still getting syntax errors even on using correct format. Need help here.
Tried RDD, flatmap etc no syntax works.
I am trying a scenario to extract data from backend into Data frame and just retrieve Column1 list values example "ID" column from that table and pass that list of ID values into SQL query for another data extraction. Tried the below line and it gives me array of response like the one i pasted here:
row_list = df.select('Column_header').collect()
Response:
[Row(Column_header='Value1'), Row(Column_header='Value2')........]
What I would like to extract is like this:
[val1,val2,val3.....]
Tried with RDD and map, but still getting syntax errors even on using correct format. Need help here.
Tried RDD, flatmap etc no syntax works.
Share Improve this question edited Mar 17 at 9:36 Yash Mehta 2,0064 gold badges12 silver badges21 bronze badges asked Mar 17 at 9:09 Kirthi ShreeKirthi Shree 32 bronze badges1 Answer
Reset to default 1There's an extra step missing:
row_list = df.select('Column_header').collect()
result = [row['Column_header'] for row in row_list]
本文标签: dataframeExtract Column values from data frame and pass into SQL pyspark where ClauseStack Overflow
版权声明:本文标题:dataframe - Extract Column values from data frame and pass into SQL pyspark where Clause - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744570896a2613332.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论