Limpeza de dados com o PySpark
Mike Metzger
Data Engineering Consultant
O caching no Spark:
Ao desenvolver tarefas no Spark:
Chame .cache() no DataFrame antes da 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()
Use .is_cached para verificar o status do cache
print(voter_df.is_cached)
True
Chame .unpersist() quando terminar com o DataFrame
voter_df.unpersist()
Limpeza de dados com o PySpark