0
votes

For example, I have csv time series data for various stocks and I would like to convert the data into vectors which would be feed-able into a neural network.

I'm not sure if this would be of any relevance but ultimately, I would want to predict future stock price based on various current fundamental metrics - TDebt, IntAssets, TAssets, and EBITDA. Then, I compare PriceToday and Price+1Yr. If the PriceDiff is positive, data is labeled Correct, if Negative, data is labeled Incorrect.

Date,Ticker, TDebt , IntAssets , TAssets , EBITDA , PriceToday , Price+1Yr , PriceDiff , Label 1/1/10,AAPL,6.73,3.05,41.16,11.06,179.26,219.26,22.31,Correct 1/1/10,GOOGL,3.19,12.54,24.08,2.63,1135.97,1115.97,-1.76,Incorrect 1/1/10,MSFT,4.32,15.74,35.84,7.43,90.1,94.1,4.44,Correct 1/1/10,AMZN,0.52,0.24,18.5,7.55,1293.32,1044.32,-19.25,Incorrect 1/1/10,FB,3.32,7.79,15.05,0.63,179.8,156.8,-12.79,Incorrect 1/1/10,BABA,13.61,18.02,122.56,25.31,184.4,205.4,11.39,Correct 1/1/10,JNJ,5.18,2.54,39.44,8.06,146.92,185.92,26.55,Correct 1/1/10,XOM,2.23,-2.17,94.32,14.52,87.43,48.43,-44.61,Incorrect 1/1/11,AAPL,7.27,3.35,42.9,12.04,219.26,230.26,5.02,Correct 1/1/11,GOOGL,4.01,12.8,24.87,2.34,1115.97,1135.97,1.79,Correct 1/1/11,MSFT,5.4,14.04,33.84,5.04,94.1,88.1,-6.38,Incorrect 1/1/11,AMZN,0.59,0.31,19.04,9.31,1044.32,1396.32,33.71,Correct 1/1/11,FB,2.8,9.08,16.04,0.74,156.8,151.8,-3.19,Incorrect 1/1/11,BABA,12.68,19.03,124.05,24.03,205.4,216.4,5.36,Correct 1/1/11,JNJ,6.01,2.7,37.04,10.02,185.92,174.92,-5.92,Incorrect 1/1/11,XOM,2.8,-2.9,93.1,13.23,48.43,78.43,61.95,Correct 1/1/12,AAPL,7.18,-4.88,67.78,26.03,230.26,209.26,-9.12,Incorrect 1/1/12,GOOGL,1.05,0.47,102.09,11.29,1135.97,1145.97,0.88,Correct 1/1/12,MSFT,6.45,-5.68,59.01,21.42,88.1,58.1,-34.05,Incorrect 1/1/12,AMZN,6.23,1.59,19.44,6.91,1396.32,1276.32,-8.59,Incorrect 1/1/12,FB,6.08,-1.15,53.7,13.43,151.8,156.8,3.29,Correct 1/1/12,BABA,10.89,12.57,194.62,20.91,216.4,204.4,-5.55,Incorrect 1/1/12,JNJ,5.88,5.48,78.08,12.8,174.92,184.92,5.72,Correct 1/1/12,XOM,14.57,0.92,121.11,13.76,78.43,66.43,-15.3,Incorrect

Thank you for your help.

1
read it using pandas, then convert to whatever format you need using their conversions. Pandas stores data as numpy arrays so you're basically done thenevamicur
Can you please provide an example of the code you would run to do this? Thank you.michael0196

1 Answers

1
votes

As @evamicur is explaining, you should use pandas library to convert your date. I would do something like, but you should edit to your need:

import pandas as pd

df = pd.read_csv('my.csv')

df['Date'] = pd.to_datetime(df['Date'])

df.set_index('Date', inplace=True)

Note, I would also change my label to either 0 or 1 instead of 'Correct' and 'Incorrect' for your NN.

df[' Label '] = df[' Label '].map({'Correct ': 1, 'Incorrect ': 0})

You should also get rid of all the spaces in your csv file. Hope this help.