0

I am relatively new to coding and I wanted to try my hand at building code to back-test data, but I am having some issue with extracting a column from my data into a numpy array. Below I have screen shots of how I want it to be formatted and the issues I am running into. Any help would be appreciated.

import numpy 
import talib
from numpy import genfromtxt

my_data = genfromtxt('1_DAY.csv', delimiter=",")

print(my_data)

close = my_data[:,4]

print(close)

(https://i.stack.imgur.com/g7rm4.png)

But I keep getting this output...

PS C:\Users\Namaste\Documents\GitHub\binance-tutorials\coinview> conda activate base

PS C:\Users\Namaste\Documents\GitHub\binance-tutorials\coinview> & C:/Users/Namaste/Anaconda3/python.exe

C:/Users/Namaste/Documents/GitHub/binance-tutorials/coinview/ta.py Traceback (most recent call last):

File "c:/Users/Namaste/Documents/GitHub/binance-tutorials/coinview/ta.py", line 5, in my_data = genfromtxt('1_DAY.csv', delimiter=",")

File "C:\Users\Namaste\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 1749, in genfromtxt fid = np.lib._datasource.open(fname, 'rt', encoding=encoding)

File "C:\Users\Namaste\Anaconda3\lib\site-packages\numpy\lib_datasource.py", line 195, in open return ds.open(path, mode, encoding=encoding, newline=newline)

File "C:\Users\Namaste\Anaconda3\lib\site-packages\numpy\lib_datasource.py", line 535, in open raise IOError("%s not found." % path)

OSError: 1_DAY.csv not found. (https://i.stack.imgur.com/JERv3.png)

But I am trying to get the data to look like this... (https://i.stack.imgur.com/QvNvu.png)

I've read online that pandas is better for csv file but I am using TA-Lib and it uses numpy to build arrays.

  • The `not found` error means you have given it the wrong path, directory and/or name. Switching to `pandas` won't help. – hpaulj Nov 23 '20 at 02:57
  • Thank you for pointing that out. I fixed it by adding "\\" so it finds the file in the right directory. When i run it again, the data doesn't come out in the format I want it to. It looks like this... [[1.50292800e+09 3.01130000e+02 3.12180000e+02 ... 6.22458999e+03 1.90870537e+06 5.05798723e+04] [1.50301440e+09 3.02000000e+02 3.11790000e+02 ... 7.45243542e+03 2.24081326e+06 5.53295743e+04] [1.50310080e+09 2.93310000e+02 2.99900000e+02 ... 1.53797550e+03 4.44713612e+05 5.80051710e+04] . – Marcus Knight Nov 23 '20 at 05:26

0 Answers0