Apache Spark Deep Learning Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

This section walks through the steps to convert the dataframe into an array:

  1. View the data collected from the dataframe using the following script:
df.select("height", "weight", "gender").collect()
  1. Store the values from the collection into an array called data_array using the following script:
data_array =  np.array(df.select("height", "weight", "gender").collect())
  1. Execute the following script to access the first row of the array:
data_array[0]
  1. Similarly, execute the following script to access the final row of the array:
data_array[28]