การตรวจสอบข้อมูลใน PySpark DataFrame
การตรวจสอบข้อมูลเบื้องต้นเป็นขั้นตอนสำคัญก่อนเริ่มวิเคราะห์ ไม่ว่าจะเป็นการพล็อตกราฟ การสร้างโมเดล หรือการเทรน ในแบบฝึกหัดนี้ จะได้ตรวจสอบข้อมูลใน DataFrame people_df ที่สร้างไว้ในแบบฝึกหัดก่อนหน้า โดยใช้ตัวดำเนินการพื้นฐานของ DataFrame
โดย SparkSession spark และ DataFrame people_df พร้อมใช้งานใน workspace ของคุณแล้ว
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Big Data Fundamentals with PySpark
คำแนะนำการฝึกหัด
- แสดงข้อมูล 10 แถวแรกใน DataFrame
people_df - นับจำนวนแถวทั้งหมดใน DataFrame
people_df - DataFrame
people_dfมีกี่คอลัมน์ และแต่ละคอลัมน์มีชื่อว่าอะไร?
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# 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.____))