import re # Convert product reviews to a string text = pd.Series.to_string(data['text'], index = False) # Remove newline characters text = re.sub('n', '', text) # Calculate sum of numbers, letters, and spaces numbers = sum(c.isdigit() for c in text) letters = sum(c.isalpha() for c in text) spaces = sum(c.isspace() for c in text) others = len(text) - numbers - letters - spaces