I calculated a frequency dataframe. However I would need rename the first column (there is no name, as shown below).
Frequency
Trump won election 46
US working vaccine 45
seqirus coronavirus vitamine 45
... ...
Apple closed shops 1
still water helps 1
created by
freq = sum(sparse_matrix).toarray()[0]
df=pd.DataFrame(freq, index=word_vectorizer.get_feature_names(), columns=['Frequency'])
df=df.sort_values(by='Frequency', ascending=False)
I have tried with
df = df.rename(columns={'index':'Words'})
But nothing has changed. My expected output would be:
Words Frequency
Trump won election 46
US working vaccine 45
seqirus coronavirus vitamine 45
... ...
Apple closed shops 1
still water helps 1
Any help would be appreciated. Thank you