Guest User

Untitled

a guest
Jun 24th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. [datetime.datetime(2009, 4, 15, 21, 58, 14), 0]
  2.  
  3. with open('newdata.txt') as f:
  4. for line in f:
  5. tweet=re.sub(r'Tt',"",line)
  6. t=re.sub(r'Wt',"//",tweet)
  7. data=t.split("//")
  8. sentiment_value= s.sentiment(data[1])
  9. data.append(sentiment_value)
  10.  
  11. words = [w.replace('pos', '1') for w in data]
  12. word=[w.replace('neg','0')for w in words]
  13. del word[1]
  14. word[1]=int(word[1])
  15.  
  16. word[0]=datetime.strptime(word[0],'%Y-%m-%d %H:%M:%S ')
  17. print(word)
  18.  
  19. values= (word)
  20. ax = plt.subplot(111)
  21. ax.plot_date([value[0] for value in values], [value[1] for value in values], "-o")
  22. plt.show()
  23.  
  24. TypeError: 'datetime.datetime' object is not subscriptable
  25.  
  26. word[0]=matplotlib.dates.date2num(word[0])
  27.  
  28. TypeError: 'float' object is not subscriptable
Add Comment
Please, Sign In to add comment