1 from pyspark.sql import SparkSession
2 from similarities_helper import build_tfidf_dataset
5 spark = SparkSession.builder.getOrCreate()
7 df = spark.read.parquet("/gscratch/comdata/users/nathante/reddit_tfidf_test_authors.parquet_temp")
9 include_subs = pd.read_csv("/gscratch/comdata/users/nathante/cdsc-reddit/subreddits_by_num_comments.csv")
11 #include_subs = set(include_subs.loc[include_subs.comments_rank < 300]['subreddit'])
13 # remove [deleted] and AutoModerator (TODO remove other bots)
14 df = df.filter(df.author != '[deleted]')
15 df = df.filter(df.author != 'AutoModerator')
17 df = build_tfidf_dataset(df, include_subs, 'author')
19 df.write.parquet('/gscratch/comdata/users/nathante/subreddit_tfidf_authors.parquet',mode='overwrite',compression='snappy')