如何使用 pushshift 获得得分最高的 sub-reddit 提交?

How do I get the sub-reddit submission with the highest score with pushshift?

我是初学者,如果这完全错误,我很抱歉。到目前为止,我已经能够显示所需的字段(作者、subreddit、创建日期、评论数量、分数、提交标题、提交描述)并将其保存到数据框中。但是当复杂的问题开始时,我突然迷路了,比如这个问题以及一周中的哪一天提交最多。这是我现在获得最高分的提交:

subreddit = pd.read_csv('subreddit.csv', delimiter = ',')
subreddit.count()

score = "score"
h_score = subreddit.score.max()
best_submission = subreddit.score(h_score) #it comes out as TypeError: 'Series' object is not callable here
bsubmission_title = title[best_submission]
print("Submission with the highest score:", bsubmission_title)

subreddit.score.max() returns score 列中的最大值。但是您想获得与该分数位于同一行的标题。为了得到它,您不需要分数值,而是分数值最高的行的索引。你可以用 idxmax 得到这个。然后您可以使用索引来获取匹配的标题:

h_score_index = subreddit.score.idxmax()
bsubmission_title = subreddit.title[h_score_index]
print("Submission with the highest score:", bsubmission_title)