import pandas as pd
df =pd . read _csv(“AmazonReview.csv”)your text
print(df. head(5))
print(df.info())
print(df. shape)
print(“Null Values:n”, df .is na().sum())
Define a function to count the number of words in a review
def count_words(review):
if isinstance(review, str):
return len(review.split())
return 0
Apply the function to the review_text column to create a new column ‘word_count’
df[‘word_count’] = df[‘Review’].apply(count_words)
# Print the first few rows to verify
print(df.head())
Plot the histogram of word counts
but in output it is showing only this
[Running] python -u “e:python1word count.py”
Review Sentiment
0 Fast shipping but this product is very cheaply… 1
1 This case takes so long to ship and it’s not e… 1
2 Good for not droids. Not good for iPhones. You… 1
3 The cable was not compatible between my macboo… 1
4 The case is nice but did not have a glow light… 1
Review Sentiment word_count
0 Fast shipping but this product is very cheaply… 1 42
1 This case takes so long to ship and it’s not e… 1 15
2 Good for not droids. Not good for iPhones. You… 1 29
3 The cable was not compatible between my macboo… 1 20
4 The case is nice but did not have a glow light… 1 20
[Done] exited with code=0 in 1.912 seconds
why
i think it should print every print statement but it is showing only some
Bhavya Jain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.