Merging the values

Before we move onto the machine learning elements, there is one more quick step to accomplish. We need to merge each individual stock datasets together so we can do analysis overall.

The code to do this is pretty self explanatory so it is posted below.

sentiment.py

import csv
import pandas as pd
import glob

allFiles = glob.glob("finaldata/*.csv")
frame = pd.DataFrame()
list_ = []
for file_ in allFiles:
    df = pd.read_csv(file_,index_col=0,encoding='latin-1')
    df = df.drop('text', 1)
    df = df.drop('date', 1)
    list_.append(df)
frame = pd.concat(list_)

frame.to_csv('final.csv')