WordCount
Task:Count the number of words in a file.
Python
1 | data=pd.read_csv(file,sep="\n",header=None) |
2 | tmp=[] |
3 | data=data.iloc[:,0].apply(lambda x:tmp.extend(x.split())) |
4 | pd.Series(1,tmp).groupby(level=0).count() |
It's just to split the contents by empty characters. It will be very troublesome to remove other punctuations that do not have statistical meanings.
esProc
A | |||
1 | =lower(file("T.txt").read()).words().groups(~:word;count(1):count) |
esProc provides the word() function to split the string into words, and a one-liner can complete the task.