การทำความสะอาดข้อมูลด้วย PySpark
Mike Metzger
Data Engineering Consultant
Caching ใน Spark:
เมื่อพัฒนา Spark task:
เรียก .cache() บน DataFrame ก่อน Action
voter_df = spark.read.csv('voter_data.txt.gz')
voter_df.cache().count()
voter_df = voter_df.withColumn('ID', monotonically_increasing_id())
voter_df = voter_df.cache()
voter_df.show()
ตรวจสอบสถานะแคชด้วย .is_cached
print(voter_df.is_cached)
True
เรียก .unpersist() เมื่อใช้งาน DataFrame เสร็จแล้ว
voter_df.unpersist()
การทำความสะอาดข้อมูลด้วย PySpark