Skip to content

Instantly share code, notes, and snippets.

@shashankvemuri
Created May 25, 2020 03:19
Show Gist options
  • Select an option

  • Save shashankvemuri/9d215b4e10f8e4047f0f430d7e19f926 to your computer and use it in GitHub Desktop.

Select an option

Save shashankvemuri/9d215b4e10f8e4047f0f430d7e19f926 to your computer and use it in GitHub Desktop.
view the data
# View Data
news['Date'] = pd.to_datetime(news.Date).dt.date
unique_ticker = news['Ticker'].unique().tolist()
news_dict = {name: news.loc[news['Ticker'] == name] for name in unique_ticker}
values = []
for ticker in tickers:
dataframe = news_dict[ticker]
dataframe = dataframe.set_index('Ticker')
dataframe = dataframe.drop(columns = ['Headline'])
print ('\n')
print (dataframe.head())
mean = round(dataframe['compound'].mean(), 2)
values.append(mean)
df = pd.DataFrame(list(zip(tickers, values)), columns =['Ticker', 'Mean Sentiment'])
df = df.set_index('Ticker')
df = df.sort_values('Mean Sentiment', ascending=False)
print ('\n')
print (df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment