get specific row from spark dataframe

前端 未结 9 1721
闹比i
闹比i 2020-12-17 07:58

Is there any alternative for df[100, c(\"column\")] in scala spark data frames. I want to select specific row from a column of spark data frame. for example

9条回答
  •  心在旅途
    2020-12-17 08:19

    In PySpark, if your dataset is small (can fit into memory of driver), you can do

    df.collect()[n]
    

    where df is the DataFrame object, and n is the Row of interest. After getting said Row, you can do row.myColumn or row["myColumn"] to get the contents, as spelled out in the API docs.

提交回复
热议问题