Guest User

Untitled

a guest
May 5th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import pandas as pd
  2. #import matplotlib.pyplot as plt
  3. #import numpy as np
  4. #import matplotlib.font_manager as fm
  5.  
  6. reddit = praw.Reddit(client_id='',
  7. client_secret='',
  8. password='',
  9. user_agent='footballer by /u/kunalc',
  10. username='kunalc')
  11.  
  12. submissions=reddit.subreddit('soccer').top(limit=500)
  13. submissions=list(submissions)
  14. print(len(submissions))
  15.  
  16. dicta={}
  17.  
  18.  
  19. for submission in submissions:
  20. title=submission.title
  21. data=title.split()
  22. for word in data:
  23. if word[0].isupper():
  24. if word in dicta:
  25. dicta[word]=dicta[word]+1
  26. else:
  27. dicta[word]=1
  28.  
  29.  
  30. names=[]
  31. counts=[]
  32. for item in dicta:
  33. names.append(item)
  34. counts.append(dicta[item])
  35.  
  36. df=pd.DataFrame(columns=['words','counts'])
  37. df['words']=names
  38. df['counts']=counts
  39. df2=df.sort_values('counts',ascending=False)
Add Comment
Please, Sign In to add comment