3 from pyspark.sql import functions as f
4 from pyspark.sql import SparkSession
6 spark = SparkSession.builder.getOrCreate()
7 df = spark.read.parquet("/gscratch/comdata/users/nathante/reddit_tfidf_test.parquet_temp/")
9 df = df.repartition(2000,'term')
10 df = df.sort(['term','week','subreddit'])
11 df = df.sortWithinPartitions(['term','week','subreddit'])
13 df.write.parquet("/gscratch/comdata/users/nathante/reddit_tfidf_test_sorted_tf.parquet_temp",mode='overwrite',compression='snappy')