I uploaded an excel text file. I want to count the number of times each word occurs, for instance:
Output:
was 2
report 1
county 5
increase 2
Code:
news = pd.read_excel('C:\\Users\\farid-PC\\Desktop\\Tester.xlsx')
pd.set_option('display.max_colwidth', 1000)
print(news)
#implement word counter?
Current Output:
Text
0 Trump will drop a bomb on North Korea
1 Building a wall on the U.S.-Mexico border will take literally years
2 Wisconsin is on pace to double the number of layoffs this year.
3 Says John McCain has done nothing to help the vets.
4 Suzanne Bonamici supports a plan that will cut choice for Medicare
Any help will be appreciated.
news.head().to_dict()or something like that). Also, the code you provided doesn't attempt to solve the problem, it just shows how you loaded the data. Have you attempted anything so far?df.head(5). You can usecollections.Counteras well to count the frequency.