
上QQ阅读APP看书,第一时间看更新
How to do it...
This section walks through the steps to convert the dataframe into an array:
- View the data collected from the dataframe using the following script:
df.select("height", "weight", "gender").collect()
- 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())
- Execute the following script to access the first row of the array:
data_array[0]
- Similarly, execute the following script to access the final row of the array:
data_array[28]