def _frame_parser(self, file_path, index):
"""
parse nlp data
:return:
"""
try :
store = pd.HDFStore(file_path)
chunk = store.select('table1',
start=index.start,
stop=index.stop)
input_vector = []
count = index.stop - index.start
for col_name in self.encode_col:
if (chunk[col_name].dtype == 'O'):
input_vector.append(list(map(lambda x: self.encode_onehot[col_name].get_vector(x),
chunk[col_name][0:count].tolist())))
else :
input_vector.append(np.array(list(map(lambda x: [self._filter_nan(x)], chunk[col_name][0:count].tolist()))))
return self._flat_data(input_vector, len(chunk[col_name][0:count].tolist()))
except Exception as e :
raise Exception (e)
finally:
store.close()
评论列表
文章目录