How to extract a single (column/row) value from a dataframe using PySpark?

后端 未结 2 1253
故里飘歌
故里飘歌 2021-01-15 21:58

Here\'s my spark code. It works fine and returns 2517. All I want to do is to print \"2517 degrees\"...but I\'m not sure how to extract that 2517 into a variable. I can only

2条回答
  •  悲&欢浪女
    2021-01-15 22:24

    I think you're looking for collect. Something like this should get you the value:

    df.collect()[0]['count(DISTINCT AP)']
    

    assuming the column name is 'count(DISTINCT AP)'

提交回复
热议问题