def PrintOverlapPdf(self, overlaps, topic_dict): overlap_frame = pd.DataFrame( columns=['Course', 'Topic', 'Similar Course', 'Similar Topic']) for overlap in overlaps: for sub_lap in overlaps[overlap]: overlap_frame = overlap_frame.append( { 'Course': overlap[0], 'Topic': overlap[1], 'Similar Course': sub_lap[0], 'Similar Topic': sub_lap[1] }, ignore_index=True) table = overlap_frame.to_html() table_html = HTML(string=table) table_html.write_pdf('Topic Similarities.pdf') topicFrame = pd.DataFrame(columns=['Course', 'Topics']) for text in topic_dict: topicFrame = topicFrame.append( { 'Course': text, 'Topics': topic_dict[text] }, ignore_index=True) topics = topicFrame.to_html() topic_html = HTML(string=topics) topic_html.write_pdf('Generated Topics.pdf')