I would like to save the sample output from this loop to CSV
[(16.0, 'thermionic vacuum diode device'), (4.0, 'adjustable electrodes')]
[(16.0, 'thermionic vacuum diode device'), (4.0, 'adjustable electrodes')]
[(9.0, 'heat transfer device')]
This output are generated from
def write_csv():
for index, row in df.iterrows():
text = row
r.extract_keywords_from_sentences(text)
r.get_ranked_phrases()
score = r.get_ranked_phrases_with_scores()
new_df = pd.DataFrame({'col':score})
new_df = df.append(df)
#print(score)
df.to_csv("test_score_2.csv")
When I call def write_csv(), the CSV file contains only the last line, but I want to save all rows to the CSV file.
Is any suggestion?