I couldn't help but thinking if there is anyways I can do this with fewer lines:
def load_data(symbol, time_frame, folder_name='candle_dfs'):
data = np.loadtxt('{}/{}/{}-{}.csv'.format(folder_name, symbol, symbol, time_frame), delimiter=',', unpack=True, dtype=str, skiprows=1)
date = data[0]
openp = data[1]
closep = data[2]
highp = data[3]
lowp = data[4]
volume = data[5]
return date, openp, closep, highp, lowp, volume
Basically I have csv files that I used pd.to_csv() to export and now I loaded them in as a numpy array. The csv file structure looks something like this:
DATE,OPEN,CLOSE,HIGH,LOW,VOLUME
07-01-2016 00:00:00,428.2,458.78,462.0,427.11,55448.62348451
14-01-2016 00:00:00,431.09,419.55,435.0,352.5,351431.25461113
21-01-2016 00:00:00,419.65,394.97,424.57,371.25,180450.95451554
28-01-2016 00:00:00,394.7,368.98,395.48,360.03,161054.42792964
so when I loaded it in with numpy.loadtxt() and using unpack=True each column in the dataframe becomes an array which then I can set each array into a variable so I can call them later. The code above works. However, I'm just wondering if it is possible to do this part in a fewer lines:
date = data[0]
openp = data[1]
closep = data[2]
highp = data[3]
lowp = data[4]
volume = data[5]
Thank you very much for helping!