I have df from a csv file, and count the words in one column ('short_description'):
df = pd.read_csv(r'C:\Users\username\Downloads\file_to_analyse.csv')
#lists and counts all words from short description
word_counter = df.short_description.str.split(expand=True).stack().value_counts().to_string()
This gives me a all words and a number how often it is in this column. But to show it visual in a graphic (with pandas) I need to separate words = [] amount = []
Then I can create x-axis and y-axis. But actually its one big ...string? I think so.
I tried:
#separate numbers
amount = [int(s) for s in word_counter.split() if s.isdigit()]
#separate words
word_list = []
separate_words = ''.join([i for i in word_counter if not i.isdigit()])
word_list.append(separate_words)
This word_list is not giving me single words but a big string with many spaces