Khám phá dữ liệu trong PySpark DataFrame
Khám phá dữ liệu là bước rất quan trọng trước khi thực hiện các phân tích như vẽ biểu đồ, mô hình hóa, huấn luyện, v.v. Trong bài tập đơn giản này, bạn sẽ xem xét dữ liệu trong DataFrame people_df mà bạn đã tạo ở bài trước bằng các toán tử cơ bản của DataFrame.
Lưu ý, bạn đã có sẵn SparkSession spark và DataFrame people_df trong không gian làm việc của mình.
Bài tập này là một phần của khóa học
Nền tảng Big Data với PySpark
Hướng dẫn bài tập
- In 10 quan sát đầu tiên trong DataFrame
people_df. - Đếm số hàng trong DataFrame
people_df. - DataFrame
people_dfcó bao nhiêu cột và tên của chúng là gì?
Bài tập tương tác thực hành trực tiếp
Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.
# 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.____))