在 PySpark DataFrame 中检查数据
在进行绘图、建模、训练等分析之前,检查数据非常关键。在这个小练习中,您将使用基础的 DataFrame 运算符,检查上一练习中创建的 people_df DataFrame 中的数据。
请记住,您的工作区中已经提供了 SparkSession spark 和 DataFrame people_df。
本练习是课程的一部分
使用 PySpark 的大数据基础
练习说明
- 打印
people_dfDataFrame 的前 10 条观测。 - 统计
people_dfDataFrame 的行数。 people_dfDataFrame 有多少列?列名分别是什么?
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Print the first 10 observations
people_df.____(10)
# Count the number of rows
print("There are {} rows in the people_df DataFrame.".format(people_df.____()))
# Count the number of columns and print their names
print("There are {} columns in the people_df DataFrame and their names are {}".format(len(people_df.____), people_df.____))