Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import re
import pandas as pd
def special_count(string):
count = 0
for char in string:
if char.isalpha():
continue
elif char.isdigit():
continue
elif char.isspace():
continue
else:
count += 1
return count
def quote_count(string):
count = 0
for char in string:
if char == '"':
count += 1
return count
def markup_count(string):
count = len(re.findall('[<U+]......[>]',string))
return count
def punct_count(string):
count = 0
for char in string:
if char in ('!', "," ,"\'" ,";" ,"\"", ".", "-" ,"?"):
count += 1
return count
df = pd.read_csv('latest.csv',encoding='ISO-8859-1',usecols=['text'])
values = df.values
df["special_char_count"] = df["text"].apply(special_count)
df["quote_count"] = df["text"].apply(quote_count)
df["markup_count"] = df["text"].apply(markup_count)
df["punct_count"] = df["text"].apply(punct_count)