開始使用免費開始

在 PySpark DataFrame 中檢視資料

在進行繪圖、建模、訓練等分析之前,先檢視資料非常重要。這個簡單的練習中,你會用基本的 DataFrame 操作子來檢視你在上一個練習建立的 people_df DataFrame。

提醒:你的工作環境中已經有 SparkSession spark 和 DataFrame people_df 可用。

本練習屬於課程

使用 PySpark 的 Big Data 基礎

檢視課程

練習說明

  • 列印 people_df DataFrame 的前 10 筆觀察值。
  • 計算 people_df DataFrame 的列數。
  • people_df DataFrame 有多少欄?欄名是什麼?

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# 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.____))
編輯並執行程式碼