- self._dataframe = self._dataframe.drop([k.to_pydatetime()
- for k in self._dataframe.T
- if k not in self._datetimes])
+ logger.info("Dropping rows that are not related to our datetime window")
+ dates = tuple((x.year, x.month, x.day, x.hour) for x in self._datetimes)
+ self._dataframe['row_ok'] =\
+ self._dataframe.apply(lambda x: (int(x.year), int(x.month), int(x.dayInMonth), int(x.hour)) in dates, axis=1)
+ self._dataframe = self._dataframe[self._dataframe['row_ok']]
+ self._dataframe = self._dataframe.drop(['row_ok'], axis=1)
+ logger.info("Rows dropped")
+
+
+ def _add_history(self):
+ '''
+ Integrating previous nb of interventions as features
+ '''
+ logger.info("Integrating previous nb of interventions as features")
+ nb_lines = self._config['HISTORY_KNOWLEDGE'].getint('nb_lines')
+ for k in range(1,nb_lines+1):
+ name = 'history_'+str(nb_lines-k+1)
+ self._dataframe[name] = [np.NaN]*k + list(self._dict_target.values())[:-k]
+ self._numerical_columns.append(name)
+ self._dataframe = self._dataframe[nb_lines:]
+