Я новичок в кодировании и пытаюсь создать график анализа настроений
def find_symbols(ticker, symbol_records):
if ticker in [x['symbol'] for x in symbol_records]:
return True
else:
return False
my_tickers=['FB','TSLA','CSCO','MSFT','SPY']
for ticker in my_tickers:
st[ticker]= st['symbols'].apply(lambda x: find_symbols(ticker,x))
stocks_sentiment = st[st[ticker]==True]
из nltk.sentiment.vader
import SentimentIntensityAnalyzer
sid = SentimentIntensityAnalyzer()
for sentence in stocks_sentiment.body :
print(sentence)
ss = sid.polarity_scores(sentence)
for k in sorted(v_score):
print('{0}: {1}, '.format(k,ss[k]), end='')
print()
def v_score (text_string):
score = sid.polarity_scores(text_string)
return score ['compound']
import matplotlib.pyplot as plt
import matplotlib as mpl
import seaborn as sns
%matplotlib inline
%pylab inline
pylab.rcParams['figure.figsize'] = (15, 9)
score = score.resample('1T').agg({'compound': 'last'})
Составлять номер соединения каждую минуту для всеготорговый день