Created
November 10, 2018 14:14
-
-
Save beannguyen/d1f89ef2fd9d2d1120680412e5843155 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def preprocessing(file): | |
_data = [] | |
print('Processing file ', file) | |
f = open(file, 'r') | |
try: | |
df = pd.read_csv(f, delimiter=',', usecols=['date', 'open', 'high', 'low', 'close']) | |
df = df.sort_values('date') | |
df = df.drop(['date'], axis=1) | |
dataset = df.values | |
if dataset.shape[0] >= num_unrolling + look_back_step: | |
for set_i in range(dataset.shape[0] - (num_unrolling + look_back_step)): | |
set0 = dataset[set_i:set_i + num_unrolling + look_back_step] | |
for j in range(num_unrolling + look_back_step): | |
_data.append(set0[j]) | |
return np.array(_data) | |
except: | |
traceback.print_exc() | |
return None | |
finally: | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment